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]
id: sqlalchemy.Column[uuid.UUID][source]
meeting_point: sqlalchemy.Column[str | None][source]
age: sqlalchemy.Column[onegov.activity.types.BoundedIntegerRange][source]
spots: sqlalchemy.Column[onegov.activity.types.BoundedIntegerRange][source]
note: sqlalchemy.Column[str | None][source]
cost: sqlalchemy.Column[decimal.Decimal | None][source]
booking_cost: sqlalchemy.Column[decimal.Decimal | None][source]
activity_id: sqlalchemy.Column[uuid.UUID][source]
activity: sqlalchemy.orm.relationship[activity.models.activity.Activity][source]
accepted: sqlalchemy.orm.relationship[collections.abc.Sequence[activity.models.booking.Booking]][source]
period_id: sqlalchemy.Column[uuid.UUID][source]
period: sqlalchemy.orm.relationship[activity.models.period.Period][source]
cancelled: sqlalchemy.Column[bool][source]
duration: sqlalchemy.Column[int | None][source]
order: sqlalchemy.Column[int | None][source]
exclude_from_overlap_check: sqlalchemy.Column[bool][source]
exempt_from_booking_limit: sqlalchemy.Column[bool][source]
active_days: sqlalchemy.Column[list[int]][source]
weekdays: sqlalchemy.Column[list[int]][source]
seeking_volunteers: sqlalchemy.Column[bool][source]
attendee_count() sqlalchemy.sql.ColumnElement[int][source]
bookings: sqlalchemy.orm.relationship[list[activity.models.booking.Booking]][source]
dates: sqlalchemy.orm.relationship[list[activity.models.occasion_date.OccasionDate]][source]
needs: sqlalchemy.orm.relationship[list[activity.models.occasion_need.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: sqlalchemy.Column[decimal.Decimal][source]
compute_duration(dates: collections.abc.Collection[activity.models.occasion_date.OccasionDate] | None) int[source]
compute_order(dates: collections.abc.Collection[activity.models.occasion_date.OccasionDate] | None) int[source]
compute_active_days(dates: collections.abc.Collection[activity.models.occasion_date.OccasionDate] | None) list[int][source]
compute_weekdays(dates: collections.abc.Collection[activity.models.occasion_date.OccasionDate] | None) list[int][source]
observe_dates(dates: collections.abc.Collection[activity.models.occasion_date.OccasionDate] | None) None[source]
validate_dates(key: str, date: activity.models.occasion_date.OccasionDate) activity.models.occasion_date.OccasionDate[source]
observe_needs(needs: collections.abc.Collection[activity.models.occasion_need.OccasionNeed] | None) None[source]
operable: sqlalchemy.Column[bool][source]
full() bool[source]
available_spots() 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]