org.forms.allocation ==================== .. py:module:: org.forms.allocation Classes ------- .. autoapisummary:: org.forms.allocation.DateContainer org.forms.allocation.AllocationFormHelpers org.forms.allocation.AllocationRuleForm org.forms.allocation.AllocationForm org.forms.allocation.AllocationEditForm org.forms.allocation.Daypasses org.forms.allocation.DaypassAllocationForm org.forms.allocation.DaypassAllocationEditForm org.forms.allocation.RoomAllocationForm org.forms.allocation.DailyItemFields org.forms.allocation.DailyItemAllocationForm org.forms.allocation.DailyItemAllocationEditForm org.forms.allocation.RoomAllocationEditForm Functions --------- .. autoapisummary:: org.forms.allocation.choices_as_integer Module Contents --------------- .. py:class:: DateContainer Bases: :py:obj:`Protocol` Base class for protocol classes. Protocol classes are defined as:: class Proto(Protocol): def meth(self) -> int: ... Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing). For example:: class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:: class GenProto(Protocol[T]): def meth(self) -> T: ... .. py:method:: __contains__(dt: datetime.date | datetime.datetime, /) -> bool .. py:function:: choices_as_integer(choices: collections.abc.Iterable[str] | None) -> list[int] | None .. py:class:: AllocationFormHelpers .. py:method:: generate_dates(start: datetime.date | None, end: datetime.date | None, start_time: datetime.time | None = None, end_time: datetime.time | None = None, weekdays: collections.abc.Iterable[int] | None = None) -> list[tuple[datetime.datetime, datetime.datetime]] Takes the given dates and generates the date tuples. The ``except_for`` field will be considered if present, as will the ``on_holidays`` setting. .. py:method:: combine_datetime(field: str, time_field: str) -> datetime.datetime | None Takes the given date field and combines it with the given time field. .. py:method:: is_excluded(dt: datetime.datetime) -> bool .. py:class:: AllocationRuleForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`onegov.form.Form` Base form form allocation rules. .. py:property:: dates :type: onegov.core.types.SequenceOrScalar[tuple[datetime.datetime, datetime.datetime]] .. py:attribute:: title .. py:attribute:: extend .. py:property:: rule_id :type: str .. py:property:: iteration :type: int .. py:property:: last_run :type: datetime.datetime | None .. py:property:: rule :type: dict[str, Any] .. py:property:: options :type: dict[str, Any] .. py:method:: apply(resource: onegov.reservation.Resource) -> int .. py:class:: AllocationForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`onegov.form.Form`, :py:obj:`AllocationFormHelpers` Baseform for all allocation forms. Allocation forms are expected to implement the methods above (which contain a NotImplementedException). Have a look at :meth:`libres.db.scheduler.Scheduler.allocate` to find out more about those values. .. py:attribute:: request :type: onegov.org.request.OrgRequest .. py:attribute:: start .. py:attribute:: end .. py:attribute:: except_for .. py:attribute:: on_holidays .. py:attribute:: during_school_holidays .. py:attribute:: access .. py:method:: on_request() -> None .. py:method:: ensure_start_before_end() -> bool | None .. py:property:: weekdays :type: list[int] The rrule weekdays derived from the except_for field. .. py:property:: exceptions :type: DateContainer .. py:property:: ranged_exceptions :type: collections.abc.Sequence[tuple[datetime.date, datetime.date]] .. py:method:: is_excluded(dt: datetime.datetime) -> bool .. py:property:: dates :type: onegov.core.types.SequenceOrScalar[tuple[datetime.datetime, datetime.datetime]] :abstractmethod: Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: whole_day :type: bool :abstractmethod: Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: partly_available :type: bool :abstractmethod: Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: quota :type: int :abstractmethod: Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: quota_limit :type: int :abstractmethod: Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: data :type: dict[str, Any] Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:class:: AllocationEditForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`onegov.form.Form`, :py:obj:`AllocationFormHelpers` Baseform for edit forms. Edit forms differ from the base allocation form somewhat, since they don't offer a way to generate more than one allocation at a time. The dates property is therefore expected to return a single start, end dates tuple. .. py:attribute:: date .. py:attribute:: access .. py:property:: data :type: dict[str, Any] Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:method:: apply_data(data: dict[str, Any] | None) -> None .. py:class:: Daypasses .. py:attribute:: daypasses .. py:attribute:: daypasses_limit .. py:class:: DaypassAllocationForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`AllocationForm`, :py:obj:`Daypasses` Baseform for all allocation forms. Allocation forms are expected to implement the methods above (which contain a NotImplementedException). Have a look at :meth:`libres.db.scheduler.Scheduler.allocate` to find out more about those values. .. py:attribute:: whole_day :value: True Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:attribute:: partly_available :value: False Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: quota :type: int Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: quota_limit :type: int Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: dates :type: collections.abc.Sequence[tuple[datetime.datetime, datetime.datetime]] Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:class:: DaypassAllocationEditForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`AllocationEditForm`, :py:obj:`Daypasses` Baseform for edit forms. Edit forms differ from the base allocation form somewhat, since they don't offer a way to generate more than one allocation at a time. The dates property is therefore expected to return a single start, end dates tuple. .. py:attribute:: whole_day :value: True .. py:attribute:: partly_available :value: False .. py:property:: quota :type: int .. py:property:: quota_limit :type: int .. py:property:: dates :type: tuple[datetime.datetime, datetime.datetime] .. py:method:: apply_dates(start: datetime.datetime, end: datetime.datetime) -> None .. py:method:: apply_model(model: onegov.reservation.Allocation) -> None .. py:class:: RoomAllocationForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`AllocationForm` Baseform for all allocation forms. Allocation forms are expected to implement the methods above (which contain a NotImplementedException). Have a look at :meth:`libres.db.scheduler.Scheduler.allocate` to find out more about those values. .. py:attribute:: as_whole_day .. py:attribute:: start_time .. py:attribute:: end_time .. py:attribute:: is_partly_available .. py:attribute:: per_time_slot .. py:attribute:: quota_limit :value: 1 Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: quota :type: int Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: whole_day :type: bool Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: partly_available :type: bool Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: dates :type: collections.abc.Sequence[tuple[datetime.datetime, datetime.datetime]] Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:class:: DailyItemFields .. py:attribute:: items .. py:attribute:: item_limit .. py:class:: DailyItemAllocationForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`AllocationForm`, :py:obj:`DailyItemFields` Baseform for all allocation forms. Allocation forms are expected to implement the methods above (which contain a NotImplementedException). Have a look at :meth:`libres.db.scheduler.Scheduler.allocate` to find out more about those values. .. py:attribute:: whole_day :value: True Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:attribute:: partly_available :value: False Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: quota :type: int Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: quota_limit :type: int Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:property:: dates :type: collections.abc.Sequence[tuple[datetime.datetime, datetime.datetime]] Passed to :meth:`libres.db.scheduler.Scheduler.allocate`. .. py:class:: DailyItemAllocationEditForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`AllocationEditForm`, :py:obj:`DailyItemFields` Baseform for edit forms. Edit forms differ from the base allocation form somewhat, since they don't offer a way to generate more than one allocation at a time. The dates property is therefore expected to return a single start, end dates tuple. .. py:attribute:: whole_day :value: True .. py:attribute:: partly_available :value: False .. py:property:: quota :type: int .. py:property:: quota_limit :type: int .. py:property:: dates :type: tuple[datetime.datetime, datetime.datetime] .. py:method:: apply_dates(start: datetime.datetime, end: datetime.datetime) -> None .. py:method:: apply_model(model: onegov.reservation.Allocation) -> None .. py:class:: RoomAllocationEditForm(formdata: webob.multidict.MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None = None, **kwargs: Any) Bases: :py:obj:`AllocationEditForm` Baseform for edit forms. Edit forms differ from the base allocation form somewhat, since they don't offer a way to generate more than one allocation at a time. The dates property is therefore expected to return a single start, end dates tuple. .. py:attribute:: as_whole_day .. py:attribute:: start_time .. py:attribute:: end_time .. py:attribute:: per_time_slot .. py:method:: ensure_start_before_end() -> bool | None .. py:attribute:: quota_limit :value: 1 .. py:property:: quota :type: int .. py:property:: whole_day :type: bool .. py:property:: partly_available :type: bool .. py:property:: dates :type: tuple[datetime.datetime, datetime.datetime] .. py:method:: apply_dates(start: datetime.datetime, end: datetime.datetime) -> None .. py:method:: apply_model(model: onegov.reservation.Allocation) -> None .. py:method:: on_request() -> None