activity.models.booking

Module Contents

Classes

Booking

Bookings are created by users for occasions.

Attributes

BookingState

activity.models.booking.BookingState: typing_extensions.TypeAlias[source]
class activity.models.booking.Booking[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.

property dates: list[onegov.activity.models.OccasionDate][source]
property order: int | None[source]
__tablename__ = 'bookings'[source]
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]
state: Column[BookingState][source]
__table_args__ = ()[source]
user: relationship[User][source]
__hash__() int[source]

Return hash(self).

__eq__(other: object) bool[source]

Return self==value.

period_id() ColumnElement[uuid.UUID][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.

Returns:

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]
overlaps(other: Booking, with_anti_affinity_check: bool = False) bool[source]