Source code for pas.models.legislative_period

from __future__ import annotations

from datetime import date
from onegov.core.orm import Base
from onegov.core.orm.mixins import TimestampMixin
from onegov.pas.i18n import _
from onegov.search import ORMSearchable
from sqlalchemy.orm import mapped_column
from sqlalchemy.orm import Mapped
from uuid import uuid4
from uuid import UUID


[docs] class LegislativePeriod(Base, TimestampMixin, ORMSearchable):
[docs] __tablename__ = 'par_legislative_periods'
[docs] fts_type_title = _('Legislative periods')
[docs] fts_public = False
[docs] fts_title_property = 'name'
[docs] fts_properties = {'name': {'type': 'text', 'weight': 'A'}}
@property
[docs] def fts_suggestion(self) -> str: return self.name
#: The polymorphic type of legislative period
[docs] type: Mapped[str] = mapped_column(default=lambda: 'generic')
[docs] __mapper_args__ = { 'polymorphic_on': type, 'polymorphic_identity': 'pas_legislative_period', }
@property
[docs] def title(self) -> str: return self.name
#: Internal ID
[docs] id: Mapped[UUID] = mapped_column( primary_key=True, default=uuid4 )
#: The start date
[docs] start: Mapped[date]
#: The end date
[docs] end: Mapped[date]
#: The name
[docs] name: Mapped[str]