AKModel.availability.models module

class AKModel.availability.models.Availability(*args, **kwargs)[source]

Bases: Model

Database table: AKModel_availability

The Availability class models when people or rooms are available for.

The power of this class is not within its rather simple data model, but with the operations available on it. An availability object can span multiple days, but due to our choice of input widget, it will usually only span a single day at most.

Parameters:

Relationship fields:

Parameters:
  • event (ForeignKey to Event) – Event. Associated event (related name: availabilities)

  • person (ForeignKey to AKOwner) – Person. Person whose availability this is (related name: availabilities)

  • room (ForeignKey to Room) – Room. Room whose availability this is (related name: availabilities)

  • ak (ForeignKey to AK) – AK. AK whose availability this is (related name: availabilities)

  • ak_category (ForeignKey to AKCategory) – AK Category. AK Category whose availability this is (related name: availabilities)

all_day

Checks if the Availability spans one (or, technically: multiple) complete day.

overlaps(other: Availability, strict: bool) bool[source]

Test if two Availabilities overlap.

Parameters:
  • other

  • strict – Only count a real overlap as overlap, not direct adjacency.

contains(other: Availability) bool[source]

Tests if this availability starts before and ends after the other.

merge_with(other: Availability) Availability[source]

Return a new Availability which spans the range of this one and the given one.

intersect_with(other: Availability) Availability[source]

Return a new Availability which spans the range covered both by this one and the given one.

classmethod union(availabilities: List[Availability]) List[Availability][source]

Return the minimal list of Availability objects which are covered by at least one given Availability.

classmethod intersection(*availabilitysets: List[Availability]) List[Availability][source]

Return the list of Availabilities which are covered by all of the given sets.

property simplified

Get a simplified (only Weekday, hour and minute) string representation of an availability :return: simplified string version :rtype: str

classmethod with_event_length(event, person=None, room=None, ak=None, ak_category=None)[source]

Create an availability covering exactly the time between event start and event end. Can e.g., be used to create default availabilities.

Parameters:
  • event – relevant event

  • person – person, if availability should be connected to a person

  • room – room, if availability should be connected to a room

  • ak – ak, if availability should be connected to a ak

  • ak_category – ak_category, if availability should be connected to a ak_category

Returns:

availability associated to the entity oder entities selected

Return type:

Availability