Source code for recipient.collection

from onegov.core.collection import GenericCollection
from onegov.recipient.model import GenericRecipient

from typing import TypeVar, TYPE_CHECKING
if TYPE_CHECKING:
    from sqlalchemy.orm import Query, Session

[docs] _RecipientT = TypeVar('_RecipientT', bound=GenericRecipient)
[docs] class GenericRecipientCollection(GenericCollection[_RecipientT]): def __init__(self, session: 'Session', type: str): super().__init__(session)
[docs] self.type = type
@property
[docs] def model_class(self) -> type[_RecipientT]: return GenericRecipient.get_polymorphic_class( # type:ignore self.type, GenericRecipient) # type:ignore[arg-type]
[docs] def query(self) -> 'Query[_RecipientT]': return super().query().order_by(self.model_class.order)