winterthur.collections.mission_report

Attributes

T

Classes

MissionReportFileCollection

Manages files.

MissionReportCollection

Abstract base class for generic types.

MissionReportVehicleCollection

Abstract base class for generic types.

Module Contents

winterthur.collections.mission_report.T[source]
class winterthur.collections.mission_report.MissionReportFileCollection(session: sqlalchemy.orm.Session, report: onegov.winterthur.models.MissionReport)[source]

Bases: onegov.org.models.file.BaseImageFileCollection[onegov.winterthur.models.MissionReportFile]

Manages files.

Parameters:
  • session – The SQLAlchemy db session to use.

  • type – The polymorphic type to use and to filter for, or ‘*’ for all.

  • allow_duplicates

    Prevents duplicates if set to false. Duplicates are detected before pre-processing, so already stored files may be downloaded and added again, as they might have changed during the upload.

    Note that this does not change existing files. It only prevents new duplicates from being added.

report[source]
property id: uuid.UUID[source]
property association: onegov.core.orm.abstract.associable.RegisteredLink[source]
add(*args, **kwargs)[source]

Adds a file with the given filename. The content maybe either in bytes or a file object.

query() Query[MissionReportFile][source]
class winterthur.collections.mission_report.MissionReportCollection(session: sqlalchemy.orm.Session, page: int = 0, include_hidden: bool = False, year: int | None = None)[source]

Bases: onegov.core.collection.GenericCollection[onegov.winterthur.models.MissionReport], onegov.core.collection.Pagination[onegov.winterthur.models.MissionReport]

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
session[source]
page = 0[source]
include_hidden = False[source]
year[source]
property model_class: type[onegov.winterthur.models.MissionReport][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.

by_id(id: uuid.UUID) onegov.winterthur.models.MissionReport | None[source]
query() Query[MissionReport][source]
query_all() Query[MissionReport][source]
query_current_year() Query[MissionReport][source]
subset() Query[MissionReport][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) Self[source]

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

filter_by_year(query: Query[T]) Query[T][source]
mission_count() int | None[source]

The mission count, including hidden missions.

class winterthur.collections.mission_report.MissionReportVehicleCollection(session: sqlalchemy.orm.Session, **kwargs: Any)[source]

Bases: onegov.core.collection.GenericCollection[onegov.winterthur.models.MissionReportVehicle]

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.winterthur.models.MissionReportVehicle][source]
query() Query[MissionReportVehicle][source]