org.forms.allocation

Classes

DateContainer

Base class for protocol classes.

AllocationFormHelpers

AllocationRuleForm

Base form form allocation rules.

AllocationForm

Baseform for all allocation forms. Allocation forms are expected

AllocationEditForm

Baseform for edit forms. Edit forms differ from the base allocation

Daypasses

DaypassAllocationForm

Baseform for all allocation forms. Allocation forms are expected

DaypassAllocationEditForm

Baseform for edit forms. Edit forms differ from the base allocation

RoomAllocationForm

Baseform for all allocation forms. Allocation forms are expected

DailyItemFields

DailyItemAllocationForm

Baseform for all allocation forms. Allocation forms are expected

DailyItemAllocationEditForm

Baseform for edit forms. Edit forms differ from the base allocation

RoomAllocationEditForm

Baseform for edit forms. Edit forms differ from the base allocation

Functions

choices_as_integer(→ list[int] | None)

Module Contents

class org.forms.allocation.DateContainer[source]

Bases: 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:
        ...
__contains__(dt: datetime.date | datetime.datetime, /) bool[source]
org.forms.allocation.choices_as_integer(choices: Iterable[str] | None) list[int] | None[source]
class org.forms.allocation.AllocationFormHelpers[source]
generate_dates(start: datetime.date | None, end: datetime.date | None, start_time: datetime.time | None = None, end_time: datetime.time | None = None, weekdays: Iterable[int] | None = None) list[tuple[datetime.datetime, datetime.datetime]][source]

Takes the given dates and generates the date tuples.

The except_for field will be considered if present, as will the on_holidays setting.

combine_datetime(field: str, time_field: str) datetime.datetime | None[source]

Takes the given date field and combines it with the given time field.

is_excluded(dt: datetime.datetime) bool[source]
class org.forms.allocation.AllocationRuleForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: onegov.form.Form

Base form form allocation rules.

property dates: onegov.core.types.SequenceOrScalar[tuple[datetime.datetime, datetime.datetime]][source]
title[source]
extend[source]
property rule_id: str[source]
property iteration: int[source]
property last_run: datetime.datetime | None[source]
property rule: dict[str, Any][source]
property options: dict[str, Any][source]
apply(resource: onegov.reservation.Resource) int[source]
class org.forms.allocation.AllocationForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: onegov.form.Form, AllocationFormHelpers

Baseform for all allocation forms. Allocation forms are expected to implement the methods above (which contain a NotImplementedException).

Have a look at libres.db.scheduler.Scheduler.allocate() to find out more about those values.

request: onegov.org.request.OrgRequest[source]
start[source]
end[source]
except_for[source]
on_holidays[source]
during_school_holidays[source]
access[source]
on_request() None[source]
ensure_start_before_end() bool | None[source]
property weekdays: list[int][source]

The rrule weekdays derived from the except_for field.

property exceptions: DateContainer[source]
property ranged_exceptions: Sequence[tuple[date, date]][source]
is_excluded(dt: datetime.datetime) bool[source]
property dates: SequenceOrScalar[tuple[datetime, datetime]][source]
Abstractmethod:

Passed to libres.db.scheduler.Scheduler.allocate().

property whole_day: bool[source]
Abstractmethod:

Passed to libres.db.scheduler.Scheduler.allocate().

property partly_available: bool[source]
Abstractmethod:

Passed to libres.db.scheduler.Scheduler.allocate().

property quota: int[source]
Abstractmethod:

Passed to libres.db.scheduler.Scheduler.allocate().

property quota_limit: int[source]
Abstractmethod:

Passed to libres.db.scheduler.Scheduler.allocate().

property data: dict[str, Any][source]

Passed to libres.db.scheduler.Scheduler.allocate().

class org.forms.allocation.AllocationEditForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: onegov.form.Form, 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.

date[source]
access[source]
property data: dict[str, Any][source]

Passed to libres.db.scheduler.Scheduler.allocate().

apply_data(data: dict[str, Any] | None) None[source]
class org.forms.allocation.Daypasses[source]
daypasses[source]
daypasses_limit[source]
class org.forms.allocation.DaypassAllocationForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: AllocationForm, Daypasses

Baseform for all allocation forms. Allocation forms are expected to implement the methods above (which contain a NotImplementedException).

Have a look at libres.db.scheduler.Scheduler.allocate() to find out more about those values.

whole_day = True[source]

Passed to libres.db.scheduler.Scheduler.allocate().

partly_available = False[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property quota: int[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property quota_limit: int[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property dates: Sequence[tuple[datetime, datetime]][source]

Passed to libres.db.scheduler.Scheduler.allocate().

class org.forms.allocation.DaypassAllocationEditForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: AllocationEditForm, 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.

whole_day = True[source]
partly_available = False[source]
property quota: int[source]
property quota_limit: int[source]
property dates: tuple[datetime.datetime, datetime.datetime][source]
apply_dates(start: datetime.datetime, end: datetime.datetime) None[source]
apply_model(model: onegov.reservation.Allocation) None[source]
class org.forms.allocation.RoomAllocationForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: AllocationForm

Baseform for all allocation forms. Allocation forms are expected to implement the methods above (which contain a NotImplementedException).

Have a look at libres.db.scheduler.Scheduler.allocate() to find out more about those values.

as_whole_day[source]
start_time[source]
end_time[source]
is_partly_available[source]
per_time_slot[source]
quota_limit = 1[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property quota: int[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property whole_day: bool[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property partly_available: bool[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property dates: Sequence[tuple[datetime, datetime]][source]

Passed to libres.db.scheduler.Scheduler.allocate().

class org.forms.allocation.DailyItemFields[source]
items[source]
item_limit[source]
class org.forms.allocation.DailyItemAllocationForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: AllocationForm, DailyItemFields

Baseform for all allocation forms. Allocation forms are expected to implement the methods above (which contain a NotImplementedException).

Have a look at libres.db.scheduler.Scheduler.allocate() to find out more about those values.

whole_day = True[source]

Passed to libres.db.scheduler.Scheduler.allocate().

partly_available = False[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property quota: int[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property quota_limit: int[source]

Passed to libres.db.scheduler.Scheduler.allocate().

property dates: Sequence[tuple[datetime, datetime]][source]

Passed to libres.db.scheduler.Scheduler.allocate().

class org.forms.allocation.DailyItemAllocationEditForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: AllocationEditForm, 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.

whole_day = True[source]
partly_available = False[source]
property quota: int[source]
property quota_limit: int[source]
property dates: tuple[datetime.datetime, datetime.datetime][source]
apply_dates(start: datetime.datetime, end: datetime.datetime) None[source]
apply_model(model: onegov.reservation.Allocation) None[source]
class org.forms.allocation.RoomAllocationEditForm(formdata: 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: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: 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.

as_whole_day[source]
start_time[source]
end_time[source]
per_time_slot[source]
ensure_start_before_end() bool | None[source]
quota_limit = 1[source]
property quota: int[source]
property whole_day: bool[source]
property partly_available: bool[source]
property dates: tuple[datetime.datetime, datetime.datetime][source]
apply_dates(start: datetime.datetime, end: datetime.datetime) None[source]
apply_model(model: onegov.reservation.Allocation) None[source]
on_request() None[source]