activity.models.period

Classes

PeriodMixin

PeriodMetaBase

PeriodMeta

Built-in immutable sequence.

Period

Mixin providing created/modified timestamps for all records.

Module Contents

class activity.models.period.PeriodMixin[source]
timezone: ClassVar[str] = 'Europe/Zurich'[source]
property active: sqlalchemy.Column[bool] | bool[source]
as_local_datetime(day: datetime.date | datetime.datetime, end_of_day: bool = False) datetime.datetime[source]

Returns the moment of midnight in terms of the timezone it UTC

property phase: str | None[source]
property wishlist_phase: bool[source]
property booking_phase: bool[source]
property payment_phase: bool[source]
property execution_phase: bool[source]
property archive_phase: bool[source]
property is_prebooking_in_future: bool[source]
property is_currently_prebooking: bool[source]
property is_prebooking_in_past: bool[source]

Returns true if current date is after start of booking phase or if current date is after prebooking end.

property is_booking_in_future: bool[source]
property is_currently_booking: bool[source]
property is_booking_in_past: bool[source]
property is_execution_in_past: bool[source]
property booking_limit: int | None[source]

Returns the max_bookings_per_attendee limit if it applies.

class activity.models.period.PeriodMetaBase[source]

Bases: NamedTuple

id: uuid.UUID[source]
title: str[source]
active: bool[source]
confirmed: bool[source]
confirmable: bool[source]
finalized: bool[source]
finalizable: bool[source]
archived: bool[source]
prebooking_start: datetime.date[source]
prebooking_end: datetime.date[source]
booking_start: datetime.date[source]
booking_end: datetime.date[source]
execution_start: datetime.date[source]
execution_end: datetime.date[source]
max_bookings_per_attendee: int | None[source]
booking_cost: Decimal | None[source]
all_inclusive: bool[source]
pay_organiser_directly: bool[source]
minutes_between: int | None[source]
alignment: str | None[source]
deadline_days: int | None[source]
book_finalized: bool[source]
cancellation_date: datetime.date | None[source]
cancellation_days: int | None[source]
age_barrier_type: str[source]
class activity.models.period.PeriodMeta[source]

Bases: PeriodMetaBase, PeriodMixin

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

materialize(session: sqlalchemy.orm.Session) Period[source]
__setattr__(name: str, value: object) NoReturn[source]

Implement setattr(self, name, value).

class activity.models.period.Period[source]

Bases: onegov.core.orm.Base, PeriodMixin, onegov.core.orm.mixins.TimestampMixin

Mixin providing created/modified timestamps for all records.

The columns are deferred loaded as this is primarily for logging and future forensics.

__tablename__ = 'periods'[source]
id: Column[uuid.UUID][source]
title: Column[str][source]
active: Column[bool][source]
confirmed: Column[bool][source]
confirmable: Column[bool][source]
finalized: Column[bool][source]
finalizable: Column[bool][source]
archived: Column[bool][source]
prebooking_start: Column[date][source]
prebooking_end: Column[date][source]
booking_start: Column[date][source]
booking_end: Column[date][source]
execution_start: Column[date][source]
execution_end: Column[date][source]
data: Column[dict[str, Any]][source]
max_bookings_per_attendee: Column[int | None][source]
booking_cost: Column[Decimal | None][source]
all_inclusive: Column[bool][source]
pay_organiser_directly: Column[bool][source]
minutes_between: Column[int | None][source]
alignment: Column[str | None][source]
deadline_days: Column[int | None][source]
book_finalized: Column[bool][source]
cancellation_date: Column[date | None][source]
cancellation_days: Column[int | None][source]
age_barrier_type: Column[str][source]
__table_args__[source]
occasions: relationship[list[Occasion]][source]
bookings: relationship[list[Booking]][source]
invoices: relationship[list[Invoice]][source]
publication_requests: relationship[list[PublicationRequest]][source]
validate_age_barrier_type(key: str, age_barrier_type: str) str[source]
property age_barrier: onegov.activity.models.age_barrier.AgeBarrier[source]
activate() None[source]

Activates the current period, causing all occasions and activites to update their status and book-keeping.

It also makes sure no other period is active.

deactivate() None[source]

Deactivates the current period, causing all occasions and activites to update their status and book-keeping.

confirm() None[source]

Confirms the current period.

archive() None[source]

Moves all accepted activities with an occasion in this period into the archived state, unless there’s already another occasion in a period newer than the current period.

confirm_and_start_booking_phase() None[source]

Confirms the period and sets the booking phase to now.

This is mainly an internal convenience function to activate the previous behaviour before a specific booking phase date was introduced.

property scoring: onegov.activity.matching.score.Scoring[source]
materialize(session: sqlalchemy.orm.Session) Period[source]