Bookings are created by users for occasions.

Module Contents typing_extensions.TypeAlias[source]

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

Bookings are created by users for occasions.

Initially, bookings are open. In this state they represent a “wish” rather than booking.

Because bookings are wishes initially, they get a priority as well as a group code which links multiple bookings by multiple users together.

They system will try to figure out the best booking using the priority as well as the group code.

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

Return hash(self).

__eq__(other: object) bool[source]

Return self==value.

id: Column[uuid.UUID][source]
username: Column[str][source]
priority: Column[int][source]
group_code: Column[str | None][source]
attendee_id: Column[uuid.UUID][source]
occasion_id: Column[uuid.UUID][source]
cost: Column[Decimal | None][source]
score: Column[Decimal][source]
period_id() ColumnElement[uuid.UUID][source]
state: Column[BookingState][source]
user: relationship[User][source]
attendee: relationship[Attendee][source]
occasion: relationship[Occasion][source]
period: relationship[Period][source]
group_code_count(states: BookingStates | Literal['*'] = ('open', 'accepted')) int[source]

Returns the number of bookings with the same group code.

period_bound_booking_state(period: onegov.activity.models.Period) BookingState[source]

During pre-booking we don’t show the actual state of the booking, unless the occasion was cancelled, otherwise the user might see accepted bookings at a point where those states are not confirmed yet.

This methods interprets the period/state accordingly.

set_priority_bit(index: int, bit: Literal[0, 1]) None[source]

Changes the priority, setting the the nth bit from the right to the value of bit (index/n begins at 0).

The first bit (index=0) is reserved for starring/unstarring. The second bit (index=1) is reserved for nobble/unnobble.

As a result, starring is less influental than locking.

To give some context: Starring is used by the attendees to select which bookings they favor. Nobbling is used by administrators to force certain bookings to be preferred.

star(max_stars: int = 3) bool[source]

Stars the current booking, up to a limit per period and attendee.

Starring sets the star-bit to 1.


True if successful (or already set), False if over limit.

unstar() None[source]
nobble() None[source]
unnobble() None[source]
starred() bool[source]
starred() ColumnElement[bool][source]
nobbled() bool[source]
nobbled() ColumnElement[bool][source]
property dates: list[onegov.activity.models.OccasionDate][source]
property order: int | None[source]
overlaps(other: Booking, with_anti_affinity_check: bool = False) bool[source]