notice.collections
Attributes
Classes
Manage a list of official notices. |
Functions
|
Create a unique, URL-friendly name. |
Module Contents
- notice.collections._StrColumnLike: TypeAlias = ColumnElement[str] | ColumnElement[str | None] | ColumnElement[Markup] | ColumnElement[Markup | None][source]
- notice.collections.get_unique_notice_name(name: str, session: sqlalchemy.orm.Session, model_class: type[onegov.notice.models.OfficialNotice]) str [source]
Create a unique, URL-friendly name.
- class notice.collections.OfficialNoticeCollection(session: sqlalchemy.orm.Session, page: int = 0, state: NoticeState | None = None, term: str | None = None, order: str | None = None, direction: Literal['asc', 'desc'] | None = None, issues: Collection[str] | None = None, categories: Collection[str] | None = None, organizations: Collection[str] | None = None, user_ids: list[uuid.UUID] | None = None, group_ids: list[uuid.UUID] | None = None)[source]
Bases:
onegov.core.collection.Pagination
[_N
]Manage a list of official notices.
- __eq__(other: object) bool [source]
Returns True if the current and the other Pagination instance are equal. Used to find the current page in a list of pages.
- subset() Query[_N] [source]
Returns an SQLAlchemy query containing all records that should be considered for pagination.
- page_by_index(index: int) Self [source]
Returns the page at the given index. A page here means an instance of the class inheriting from the
Pagination
base class.
- for_state(state: onegov.notice.models.NoticeState) Self [source]
Returns a new instance of the collection with the given state.
- for_term(term: str | None) Self [source]
Returns a new instance of the collection with the given term.
- for_order(order: str, direction: Literal['asc', 'desc'] | None = None) Self [source]
Returns a new instance of the collection with the given ordering. Inverts the direction if the new ordering is the same as the old one and an explicit ordering is not defined.
- for_organizations(organizations: Collection[str] | None) Self [source]
Returns a new instance of the collection with the given organizations.
- for_categories(categories: Collection[str] | None) Self [source]
Returns a new instance of the collection with the given categories.
- filter_query(query: Query[_N]) Query[_N] [source]
Filters the given query by the state of the collection.
- order_query(query: Query[_N]) Query[_N] [source]
Orders the given query by the state of the collection.
- query() Query[_N] [source]
Returns a filtered and sorted query.
Filters by: - notice.state matches state - notice.user_id is in user_ids - notice.group_id is in group_ids - notice.issues has any of the issues - term is in title, text, category, organization, groupname, usernames
Orders by: - any notice columns - group name (group.name) - users real name (user.realname) - username (user.username) - username or users real name (user.name)