from __future__ import annotations
from onegov.core.orm import Base
from onegov.core.orm.mixins import TimestampMixin
from sqlalchemy import ForeignKey
from sqlalchemy.orm import mapped_column, relationship, Mapped
from uuid import uuid4, UUID
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .activity import Activity
from .period import BookingPeriod
[docs]
class PublicationRequest(Base, TimestampMixin):
""" Describes a request for publication. As users create new activities
they need to ask for publication, where the activity is reviewed before
it is made public.
This repeats each period. Every activity which should be provided again
has to be requested again. This is even possible multiple times per
period, though that should be the exception.
"""
[docs]
__tablename__ = 'publication_requests'
#: The public id of the publication request
[docs]
id: Mapped[UUID] = mapped_column(
primary_key=True,
default=uuid4
)
#: The activity linked to this request
[docs]
activity_id: Mapped[UUID] = mapped_column(ForeignKey('activities.id'))
[docs]
activity: Mapped[Activity] = relationship(
back_populates='publication_requests',
lazy='joined'
)
#: The period linked to this request
[docs]
period_id: Mapped[UUID] = mapped_column(ForeignKey('periods.id'))
[docs]
period: Mapped[BookingPeriod] = relationship(
back_populates='publication_requests',
lazy='joined'
)