activity.models.occasion

Classes

Occasion

Describes a single occurrence of an Activity. "Occurence" would have

Module Contents

class activity.models.occasion.Occasion[source]

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

Describes a single occurrence of an Activity. “Occurence” would have been a good word for it too, but that’s used by onegov.event.

So occasion it is.

__tablename__ = 'occasions'[source]
__hash__() int[source]

Return hash(self).

id: Column[uuid.UUID][source]
meeting_point: Column[str | None][source]
age: Column[BoundedIntegerRange][source]
spots: Column[BoundedIntegerRange][source]
note: Column[str | None][source]
cost: Column[Decimal | None][source]
booking_cost: Column[Decimal | None][source]
activity_id: Column[uuid.UUID][source]
activity: relationship[Activity][source]
accepted: relationship[Sequence[Booking]][source]
period_id: Column[uuid.UUID][source]
period: relationship[Period][source]
cancelled: Column[bool][source]
duration: Column[int | None][source]
order: Column[int | None][source]
exclude_from_overlap_check: Column[bool][source]
exempt_from_booking_limit: Column[bool][source]
active_days: Column[list[int]][source]
weekdays: Column[list[int]][source]
seeking_volunteers: Column[bool][source]
attendee_count() ColumnElement[int][source]
bookings: relationship[list[Booking]][source]
dates: relationship[list[OccasionDate]][source]
needs: relationship[list[OccasionNeed]][source]
on_date_change() None[source]

Date changes are not properly propagated to the observer for some reason, so we do this manually with a hook.

It’s a bit of a hack, but multiple dates per occasion had to be added at the last minute..

property anti_affinity_group: tuple[str, str][source]

Uses the activity_id/period_id as an anti-affinity group to ensure that an attendee is never given two occasions of the same activity in a single period.

If that is wanted, the attendee is meant to do this after the matching has been done, with a direct booking.

total_cost() decimal.Decimal[source]

Calculates the cost of booking a single occasion, including all costs only relevant to this occasion (i.e. excluding the all-inclusive subscription cost).

total_cost() ColumnElement[Decimal][source]
compute_duration(dates: Collection[OccasionDate] | None) int[source]
compute_order(dates: Collection[OccasionDate] | None) int[source]
compute_active_days(dates: Collection[OccasionDate] | None) list[int][source]
compute_weekdays(dates: Collection[OccasionDate] | None) list[int][source]
observe_dates(dates: Collection[OccasionDate] | None) None[source]
validate_dates(key: str, date: activity.models.occasion_date.OccasionDate) activity.models.occasion_date.OccasionDate[source]
observe_needs(needs: Collection[OccasionNeed] | None) None[source]
operable() bool[source]
full() bool[source]
available_spots() int[source]
available_spots() ColumnElement[int][source]
property max_spots: int[source]
is_past_deadline(now: datetime.datetime) bool[source]
is_past_cancellation(date: Occasion.is_past_cancellation.date) bool[source]
property deadline: datetime.date[source]

The date until which this occasion may be booked (inclusive).

property cancellation_deadline: datetime.date | None[source]

The date until which bookings of this occasion may be cancelled by a mere member (inclusive).

If mere members are not allowed to do that, the deadline returns None.

cancel() None[source]
is_too_young(birth_date: datetime.date | datetime.datetime) bool[source]
is_too_old(birth_date: datetime.date | datetime.datetime) bool[source]