org.models.search

Classes

Search

Provides collections with pagination, if they implement a few

Module Contents

class org.models.search.Search(request: onegov.org.request.OrgRequest, query: str, types: collections.abc.Iterable[str] | str | None = None, page: int = 0)[source]

Bases: onegov.core.collection.Pagination[Any]

Provides collections with pagination, if they implement a few documented properties and methods.

See onegov.ticket.TicketCollection for an example.

results_per_page = 10[source]
TYPE_LABEL_TEMPLATE[source]
request[source]
query[source]
types[source]
page = 0[source]
number_of_results: int | None = None[source]
property type: list[str] | None[source]
property available_documents: int[source]
property available_documents_per_type: dict[str, int][source]
property document_type_filter_labels: dict[str, set[str]][source]
property document_type_filter_choices: list[wtforms.fields.choices._Choice][source]
property available_results: int[source]
property q: str[source]

Returns the user’s query term from the search field of the UI

__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() sqlalchemy.orm.Query[Any][source]

Returns an SQLAlchemy query containing all records that should be considered for pagination.

property page_index: int[source]

Returns the current page index (starting at 0).

page_by_index(index: int) Search[source]

Returns the page at the given index. A page here means an instance of the class inheriting from the Pagination base class.

property batch: tuple[Any, Ellipsis][source]

Returns the elements on the current page.

property load_batch_results: tuple[Any, Ellipsis][source]

Load search results and sort upcoming events by occurrence start date.

apply_common_filters(query: Any, with_type_filter: bool = True) Any[source]

Applies common search filters like e.g. access filters.

load_batch(query: sqlalchemy.orm.Query[onegov.search.SearchIndex]) tuple[onegov.search.Searchable, Ellipsis][source]
feeling_lucky() str | None[source]
property subset_count: int[source]

Returns the total number of elements this pagination represents.

suggestions() tuple[str, Ellipsis][source]