translator_directory.collections.translator

Attributes

order_cols

Classes

TranslatorCollection

Abstract base class for generic types.

Module Contents

translator_directory.collections.translator.order_cols = ('last_name', 'drive_distance')[source]
class translator_directory.collections.translator.TranslatorCollection(app: onegov.translator_directory.app.TranslatorDirectoryApp, page: int = 0, written_langs: list[str] | None = None, spoken_langs: list[str] | None = None, monitor_langs: list[str] | None = None, order_by: str | None = None, order_desc: bool = False, user_role: str | None = None, search: str | None = None, guilds: list[str] | None = None, interpret_types: list[str] | None = None, state: str | None = 'published', admissions: list[str] | None = None, genders: list[str] | None = None)[source]

Bases: onegov.core.collection.GenericCollection[onegov.translator_directory.models.translator.Translator], onegov.core.collection.Pagination[onegov.translator_directory.models.translator.Translator]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
batch_size = 10[source]
app[source]
page = 0[source]
user_role = None[source]
search[source]
guilds = [][source]
interpret_types = [][source]
state = 'published'[source]
admissions = [][source]
genders = [][source]
written_langs = None[source]
spoken_langs = None[source]
monitor_langs = None[source]
order_by = None[source]
order_desc = False[source]
__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.

add(update_user: bool = True, **kwargs: Any) onegov.translator_directory.models.translator.Translator[source]
delete(item: onegov.translator_directory.models.translator.Translator) None[source]
confirm_current_data(item: onegov.translator_directory.models.translator.Translator) None[source]
update_user(item: onegov.translator_directory.models.translator.Translator, new_email: str | None) None[source]

Keep the translator and its user account in sync.

  • Creates a new user account if an email address is set (if not already existing).

  • Disable user accounts if an email has been deleted.

  • Change usernames if an email has changed.

  • Make sure used user accounts have the right role.

  • Make sure used user accounts are activated.

  • Make sure the password is changed if activated or disabled.

static truncate(text: str | None, maxchars: int = 25) str | None[source]
property model_class: type[onegov.translator_directory.models.translator.Translator][source]
subset() Query[Translator][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).

property order_expression: ColumnElement[Any][source]
property by_spoken_lang_expression: tuple[ColumnElement[bool], Ellipsis][source]
property by_written_lang_expression: tuple[ColumnElement[bool], Ellipsis][source]
property by_monitor_lang_expression: tuple[ColumnElement[bool], Ellipsis][source]
property by_search_term_expression: tuple[ColumnElement[bool], Ellipsis][source]

Search for any word in any field of the search columns

property by_professional_guilds_expression: tuple[ColumnElement[bool], Ellipsis][source]
property by_interpreting_types_expression: tuple[ColumnElement[bool], Ellipsis][source]
property by_admission: tuple[ColumnElement[bool], Ellipsis][source]
property by_gender: tuple[ColumnElement[bool], Ellipsis][source]
by_lastname(lastname: str) onegov.translator_directory.models.translator.Translator | None[source]
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.

property search_columns: list[ColumnElement[Any]][source]

The columns used for text search.

query() Query[Translator][source]
by_form(form: onegov.translator_directory.forms.translator.TranslatorSearchForm) Self[source]
property available_additional_professional_guilds: list[str][source]