translator_directory.collections.translator

Module Contents

Classes

TranslatorCollection

Abstract base class for generic types.

Attributes

order_cols

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
property model_class: type[onegov.translator_directory.models.translator.Translator][source]
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]
property search_columns: list[ColumnElement[Any]][source]

The columns used for text search.

property available_additional_professional_guilds: list[str][source]
batch_size = 10[source]
__eq__(other: object) bool[source]

Return self==value.

add(update_user: bool = True, **kwargs: Any) onegov.translator_directory.models.translator.Translator[source]
delete(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]
subset() Query[Translator][source]

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

page_by_index(index: int) typing_extensions.Self[source]

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

query() Query[Translator][source]
by_form(form: onegov.translator_directory.forms.translator.TranslatorSearchForm) typing_extensions.Self[source]