AKModel.models module

class AKModel.models.OptimizerTimeslot(avail: Availability, idx: int, constraints: set[str])[source]

Bases: object

Class describing a discrete timeslot. Used to interface with an optimizer.

avail: Availability

The availability object corresponding to this timeslot.

idx: int

The unique index of this optimizer timeslot.

constraints: set[str]

The set of time constraints fulfilled by this object.

merge(other: OptimizerTimeslot) OptimizerTimeslot[source]

Merge with other OptimizerTimeslot.

Creates a new OptimizerTimeslot object. Its availability is constructed by merging the availabilities of self and other, its constraints by taking the union of both constraint sets. As an index, the index of self is used.

__init__(avail: Availability, idx: int, constraints: set[str]) None
AKModel.models.merge_blocks(blocks: Iterable[list[OptimizerTimeslot]]) Iterable[list[OptimizerTimeslot]][source]

Merge iterable of blocks together.

The timeslots of all blocks are grouped into maximal blocks. Timeslots with the same start and end are identified with each other and merged (cf OptimizerTimeslot.merge). Throws a ValueError if any timeslots are overlapping but do not share the same start and end, i.e. partial overlap is not allowed.

Parameters:

blocks – iterable of blocks to merge.

Returns:

iterable of merged blocks.

Return type:

iterable over lists of OptimizerTimeslot objects

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

Bases: Model

Database table: AKModel_event

An event supplies the frame for all Aks.

Parameters:
  • id (AutoField) – Primary key: ID

  • name (CharField) – Name. Name or iteration of the event

  • slug (SlugField) – Short Form. Short name of letters/numbers/dots/dashes/underscores used in URLs.

  • place (CharField) – Place. City etc. the event takes place in

  • timezone (TimeZoneField) – Time Zone. Time Zone where this event takes place in

  • start (DateTimeField) – Start. Time the event begins

  • end (DateTimeField) – End. Time the event ends

  • reso_deadline (DateTimeField) – Resolution Deadline. When should AKs with intention to submit a resolution be done?

  • interest_start (DateTimeField) – Interest Window Start. Opening time for expression of interest. When left blank, no interest indication will be possible.

  • interest_end (DateTimeField) – Interest Window End. Closing time for expression of interest.

  • public (BooleanField) – Public event. Show this event on overview page.

  • active (BooleanField) – Active State. Marks currently active events

  • plan_hidden (BooleanField) – Plan Hidden. Hides plan for non-staff users

  • plan_published_at (DateTimeField) – Plan published at. Timestamp at which the plan was published

  • base_url (URLField) – Base URL. Prefix for wiki link construction

  • wiki_export_template_name (CharField) – Wiki Export Template Name

  • default_slot (DecimalField) – Default Slot Length. Default length in hours that is assumed for AKs in this event.

  • export_slot (DecimalField) – Export Slot Length. Slot duration in hours that is used in the timeslot discretization, when this event is exported for the solver.

  • contact_email (EmailField) – Contact email address. An email address that is displayed on every page and can be used for all kinds of questions

Reverse relationships:

Parameters:
  • akowner (Reverse ForeignKey from AKOwner) – All AK Owners of this Event (related name of event)

  • akcategory (Reverse ForeignKey from AKCategory) – All AK Categories of this Event (related name of event)

  • aktrack (Reverse ForeignKey from AKTrack) – All AK Tracks of this Event (related name of event)

  • akrequirement (Reverse ForeignKey from AKRequirement) – All AK Requirements of this Event (related name of event)

  • aktype (Reverse ForeignKey from AKType) – All AK Types of this Event (related name of event)

  • ak (Reverse ForeignKey from AK) – All AKs of this Event (related name of event)

  • room (Reverse ForeignKey from Room) – All Rooms of this Event (related name of event)

  • akslot (Reverse ForeignKey from AKSlot) – All AK Slots of this Event (related name of event)

  • akorgamessage (Reverse ForeignKey from AKOrgaMessage) – All AK Orga Messages of this Event (related name of event)

  • constraintviolation (Reverse ForeignKey from ConstraintViolation) – All Constraint Violations of this Event (related name of event)

  • defaultslot (Reverse ForeignKey from DefaultSlot) – All Default Slots of this Event (related name of event)

  • eventparticipant (Reverse ForeignKey from EventParticipant) – All Participants of this Event (related name of event)

  • akpreference (Reverse ForeignKey from AKPreference) – All AK Preferences of this Event (related name of event)

  • availabilities (Reverse ForeignKey from Availability) – All availabilities of this Event (related name of event)

  • dashboardbutton (Reverse ForeignKey from DashboardButton) – All Dashboard Buttons of this Event (related name of event)

static get_by_slug(slug)[source]

Get event by its slug

Parameters:

slug – slug of the event

Returns:

event identified by the slug

Return type:

Event

static get_next_active()[source]

Get first active event taking place :return: matching event (if any) or None :rtype: Event

get_categories_with_aks(wishes_seperately=False, filter_func=<function Event.<lambda>>, hide_empty_categories=False)[source]

Get AKCategories as well as a list of AKs belonging to the category for this event

Parameters:
  • wishes_seperately (bool) – Return wishes as individual list.

  • filter_func ((AK)->bool) – Optional filter predicate, only include AK in list if filter returns True

Returns:

list of category-AK-list-tuples, optionally the additional list of AK wishes

Return type:

list[(AKCategory, list[AK])] [, list[AK]]

get_unscheduled_wish_slots()[source]

Get all slots of wishes that are currently not scheduled :return: queryset of theses slots :rtype: QuerySet[AKSlot]

get_aks_without_availabilities()[source]

Gt all AKs that don’t have any availability at all

Returns:

generator over these AKs

Return type:

Generator[AK]

uniform_time_slots(*, slots_in_an_hour: float) Iterable[list[OptimizerTimeslot]][source]

Uniformly discretize the entire event into blocks of timeslots.

Discretizes entire event uniformly. May not necessarily result in a single block as slots with no room availability are dropped.

Parameters:

slots_in_an_hour – The percentage of an hour covered by a single slot. Determines the discretization granularity.

Yield:

Block of optimizer timeslots as the discretization result.

Ytype:

list of OptimizerTimeslot

default_time_slots(*, slots_in_an_hour: float) Iterable[list[OptimizerTimeslot]][source]

Discretize all default slots into blocks of timeslots.

In the discretization each default slot corresponds to one block.

Parameters:

slots_in_an_hour – The percentage of an hour covered by a single slot. Determines the discretization granularity.

Yield:

Block of optimizer timeslots as the discretization result.

Ytype:

list of TimeslotBlock

discretize_timeslots(*, slots_in_an_hour: float | None = None) Iterable[list[OptimizerTimeslot]][source]

“Choose discretization scheme.

Uses default_time_slots if the event has any DefaultSlot, otherwise uniform_time_slots.

Parameters:

slots_in_an_hour – The percentage of an hour covered by a single slot. Determines the discretization granularity.

Yield:

Block of optimizer timeslots as the discretization result.

Ytype:

list of TimeslotBlock

schedule_from_json(schedule: str | dict[str, Any], *, check_for_data_inconsistency: bool = True) int[source]

Load AK schedule from a json string.

Parameters:

schedule – A string that can be decoded to json, describing the AK schedule. The json data is assumed to be constructed following the output specification of the KoMa conference optimizer, cf. https://github.com/Die-KoMa/ak-plan-optimierung/wiki/Input-&-output-format

as_json_dict() dict[str, Any][source]

Return the json representation of this Event.

Returns:

The json dict representation is constructed following the input specification of the KoMa conference optimizer, cf. https://github.com/Die-KoMa/ak-plan-optimierung/wiki/Input-&-output-format

Return type:

dict[str, Any]

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

Bases: Model

Database table: AKModel_akowner

An AKOwner describes the person organizing/holding an AK.

Parameters:
  • id (AutoField) – Primary key: ID

  • name (CharField) – Nickname. Name to identify an AK owner by

  • slug (SlugField) – Slug. Slug for URL generation

  • institution (CharField) – Institution. Uni etc.

  • link (URLField) – Web Link. Link to Homepage

Relationship fields:

Parameters:

event (ForeignKey to Event) – Event. Associated event (related name: akowner)

Reverse relationships:

Parameters:
  • ak (Reverse ManyToManyField from AK) – All AKs of this AK Owner (related name of owners)

  • constraintviolation (Reverse ForeignKey from ConstraintViolation) – All Constraint Violations of this AK Owner (related name of ak_owner)

  • availabilities (Reverse ForeignKey from Availability) – All availabilities of this AK Owner (related name of person)

static get_by_slug(event, slug)[source]

Get owner by slug Will be identified by the combination of event slug and owner slug which is unique

Parameters:
  • event – event

  • slug – slug of the owner

Returns:

owner identified by slugs

Return type:

AKOwner

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

Bases: Model

Database table: AKModel_akcategory

An AKCategory describes the characteristics of an AK, e.g. content vs. recreational.

Parameters:
  • id (AutoField) – Primary key: ID

  • name (CharField) – Name. Name of the AK Category

  • color (CharField) – Color. Color for displaying

  • description (TextField) – Description. Short description of this AK Category

  • present_by_default (BooleanField) – Present by default. Present AKs of this category by default if AK owner did not specify whether this AK should be presented?

Relationship fields:

Parameters:

event (ForeignKey to Event) – Event. Associated event (related name: akcategory)

Reverse relationships:

Parameters:
  • ak (Reverse ForeignKey from AK) – All AKs of this AK Category (related name of category)

  • constraintviolation (Reverse ForeignKey from ConstraintViolation) – All Constraint Violations of this AK Category (related name of category)

  • defaultslot (Reverse ManyToManyField from DefaultSlot) – All Default Slots of this AK Category (related name of primary_categories)

  • availabilities (Reverse ForeignKey from Availability) – All availabilities of this AK Category (related name of ak_category)

static create_category_optimizer_constraints(categories: Iterable[AKCategory]) set[str][source]

Create a set of constraint strings from an AKCategory iterable.

Parameters:

categories – The iterable of categories to derive the constraint strings from.

Returns:

A set of category constraint strings, i.e. strings of the form ‘availability-cat-<cat.name>’.

Return type:

set of strings.

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

Bases: Model

Database table: AKModel_aktrack

An AKTrack describes a set of semantically related AKs.

Parameters:

Relationship fields:

Parameters:

event (ForeignKey to Event) – Event. Associated event (related name: aktrack)

Reverse relationships:

Parameters:

ak (Reverse ForeignKey from AK) – All AKs of this AK Track (related name of track)

aks_with_category()[source]

Get all AKs that belong to this track with category already joined to prevent additional SQL queries :return: queryset over the AKs :rtype: QuerySet[AK]

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

Bases: Model

Database table: AKModel_akrequirement

An AKRequirement describes something needed to hold an AK, e.g. infrastructure.

Parameters:

Relationship fields:

Parameters:

event (ForeignKey to Event) – Event. Associated event (related name: akrequirement)

Reverse relationships:

Parameters:
  • ak (Reverse ManyToManyField from AK) – All AKs of this AK Requirement (related name of requirements)

  • room (Reverse ManyToManyField from Room) – All Rooms of this AK Requirement (related name of properties)

  • constraintviolation (Reverse ForeignKey from ConstraintViolation) – All Constraint Violations of this AK Requirement (related name of requirement)

  • eventparticipant (Reverse ManyToManyField from EventParticipant) – All Participants of this AK Requirement (related name of requirements)

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

Bases: Model

Database table: AKModel_aktype

An AKType allows to associate one or multiple types with an AK, e.g., to better describe the format of that AK or to which group of people it is addressed. Types are specified per event and are an optional feature.

Parameters:

Relationship fields:

Parameters:

event (ForeignKey to Event) – Event. Associated event (related name: aktype)

Reverse relationships:

Parameters:

ak (Reverse ManyToManyField from AK) – All AKs of this AK Type (related name of types)

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

Bases: Model

Database table: AKModel_ak

An AK is a slot-based activity to be scheduled during an event.

Parameters:
  • id (AutoField) – Primary key: ID

  • name (CharField) – Name. Name of the AK

  • short_name (CharField) – Short Name. Name displayed in the schedule

  • description (TextField) – Description. Description of the AK

  • link (URLField) – Web Link. Link to wiki page

  • protocol_link (URLField) – Protocol Link. Link to protocol

  • reso (BooleanField) – Resolution Intention. Intends to submit a resolution

  • present (BooleanField) – Present this AK. Present results of this AK

  • notes (TextField) – Organizational Notes. Notes to organizers. These are public. For private notes, please use the button for private messages on the detail page of this AK (after creation/editing).

  • interest (IntegerField) – Interest. Expected number of people

  • interest_counter (IntegerField) – Interest Counter. People who have indicated interest online

  • include_in_export (BooleanField) – Export?. Include AK in wiki export?

Relationship fields:

Parameters:
  • category (ForeignKey to AKCategory) – Category. Category of the AK (related name: ak)

  • track (ForeignKey to AKTrack) – Track. Track the AK belongs to (related name: ak)

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

  • owners (ManyToManyField to AKOwner) – Owners. Those organizing the AK (related name: ak)

  • types (ManyToManyField to AKType) – Types. This AK is (related name: ak)

  • requirements (ManyToManyField to AKRequirement) – Requirements. AK’s Requirements (related name: ak)

  • conflicts (ManyToManyField to AK) – Conflicting AKs. AKs that conflict and thus must not take place at the same time (related name: conflict)

  • prerequisites (ManyToManyField to AK) – Prerequisite AKs. AKs that should precede this AK in the schedule (related name: ak)

Reverse relationships:

Parameters:
property details

Generate a detailed string representation, e.g., for usage in scheduling :return: string representation of that AK with all details :rtype: str

property owners_list

Get a list of stringified representations of all owners

Returns:

list of owners

Return type:

list[str]

property durations_list

Get a list of stringified representations of all durations of associated slots

Returns:

list of durations

Return type:

list[str]

property wish

Is the AK a wish? :return: true if wish, false if not :rtype: bool

increment_interest()[source]

Increment the interest counter for this AK by one without tracking that change to prevent an unreadable and large history

property edit_url

Get edit URL for this AK Will link to frontend if AKSubmission is active, otherwise to the edit view for this object in admin interface

Returns:

URL

Return type:

str

property detail_url

Get detail URL for this AK Will link to frontend if AKSubmission is active, otherwise to the edit view for this object in admin interface

Returns:

URL

Return type:

str

save_without_historical_record(*args, **kwargs)

Save the model instance without creating a historical record.

Make sure you know what you’re doing before using this method.

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

Bases: Model

Database table: AKModel_room

A room describes where an AK can be held.

Parameters:
  • id (AutoField) – Primary key: ID

  • name (CharField) – Name. Name or number of the room

  • location (CharField) – Location. Name or number of the location

  • capacity (IntegerField) – Capacity. Maximum number of people (-1 for unlimited).

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
property title

Get title of a room, which consists of location and name if location is set, otherwise only the name

Returns:

title

Return type:

str

as_json_dict() dict[str, Any][source]

Return a json representation of this room object.

Returns:

The json dict representation is constructed following the input specification of the KoMa conference optimizer, cf. https://github.com/Die-KoMa/ak-plan-optimierung/wiki/Input-&-output-format

Return type:

dict[str, Any]

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

Bases: Model

Database table: AKModel_akslot

An AK Mapping matches an AK to a room during a certain time.

Parameters:

Relationship fields:

Parameters:
  • ak (ForeignKey to AK) – AK. AK being mapped (related name: akslot)

  • room (ForeignKey to Room) – Room. Room the AK will take place in (related name: akslot)

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

Reverse relationships:

Parameters:
property duration_simplified

Display duration of slot in format hours:minutes, e.g. 1.5 -> “1:30”

property start_simplified

Display start time of slot in format weekday + time, e.g. “Fri 14:00”

property time_simplified

Display start and end time of slot in format weekday + time, e.g. “Fri 14:00 - 15:30” or “Fri 22:00 - Sat 02:00”

property end

Retrieve end time of the AK slot

property seconds_since_last_update

Return minutes since last update :return: minutes since last update :rtype: float

overlaps(other: AKSlot)[source]

Check whether two slots overlap

Parameters:

other – second slot to compare with

Returns:

true if they overlap, false if not:

Return type:

bool

as_json_dict() dict[str, Any][source]

Return a json representation of the AK object of this slot.

Returns:

The json dict representation is constructed following the input specification of the KoMa conference optimizer, cf. https://github.com/Die-KoMa/ak-plan-optimierung/wiki/Input-&-output-format

Return type:

dict[str, Any]

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

Bases: Model

Database table: AKModel_akorgamessage

Model representing confidential messages to the organizers/scheduling people, belonging to a certain AK

Parameters:
  • id (AutoField) – Primary key: ID

  • text (TextField) – Message text. Message to the organizers. This is not publicly visible.

  • timestamp (DateTimeField) – Timestamp

  • resolved (BooleanField) – Resolved. This message has been resolved (no further action needed)

Relationship fields:

Parameters:
  • ak (ForeignKey to AK) – AK. AK this message belongs to (related name: akorgamessage)

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

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

Bases: Model

Database table: AKModel_constraintviolation

Model to represent any kind of constraint violation

Can have two different severities: violation and warning The list of possible types is defined in ViolationType Depending on the type, different fields (references to other models) will be filled. Each violation should always be related to an event and at least on other instance of a causing entity

Parameters:
  • id (AutoField) – Primary key: ID

  • type (CharField) – Type. Type of violation, i.e. what kind of constraint was violated

  • level (PositiveSmallIntegerField) – Level. Severity level of the violation

  • comment (TextField) – Comment. Comment or further details for this violation

  • timestamp (DateTimeField) – Timestamp. Time of creation

  • manually_resolved (BooleanField) – Manually Resolved. Mark this violation manually as resolved

Relationship fields:

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

  • ak_owner (ForeignKey to AKOwner) – AK Owner. AK Owner belonging to this constraint (related name: constraintviolation)

  • room (ForeignKey to Room) – Room. Room belonging to this constraint (related name: constraintviolation)

  • requirement (ForeignKey to AKRequirement) – AK Requirement. AK Requirement belonging to this constraint (related name: constraintviolation)

  • category (ForeignKey to AKCategory) – AK Category. AK Category belonging to this constraint (related name: constraintviolation)

  • aks (ManyToManyField to AK) – AKs. AK(s) belonging to this constraint (related name: constraintviolation)

  • ak_slots (ManyToManyField to AKSlot) – AK Slots. AK Slot(s) belonging to this constraint (related name: constraintviolation)

class ViolationType(value)[source]

Bases: TextChoices

Possible types of violations with their text representation

class ViolationLevel(value)[source]

Bases: IntegerChoices

Possible severities/levels of a CV

__init__(*args, **kwargs)[source]
get_details()[source]

Get details of this constraint (all fields connected to it) :return: string of details :rtype: str

property details

Property: Details

property edit_url: str

Property: Edit URL for this CV

property level_display: str

Property: Severity as string

property type_display: str

Property: Type as string

property timestamp_display: str

Property: Creation timestamp as string

matches(other)[source]

Check whether one constraint violation instance matches another, this means has the same type, room, requirement, owner, category as well as the same lists of aks and ak slots. PK, timestamp, comments and manual resolving are ignored.

Parameters:

other (ConstraintViolation) – second instance to compare to

Returns:

true if both instances are similar in the way described, false if not

Return type:

bool

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

Bases: Model

Database table: AKModel_defaultslot

Model representing a default slot, i.e., a prefered slot to use for typical AKs in the schedule to guarantee enough breaks etc.

Parameters:

Relationship fields:

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

  • primary_categories (ManyToManyField to AKCategory) – Primary categories. Categories that should be assigned to this slot primarily (related name: defaultslot)

property start_simplified: str

Property: Simplified version of the start timetstamp (weekday, hour, minute) as string

property start_iso: str

Property: Start timestamp as ISO timestamp for usage in calendar views

property end_simplified: str

Property: Simplified version of the end timetstamp (weekday, hour, minute) as string

property end_iso: str

Property: End timestamp as ISO timestamp for usage in calendar views

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

Bases: Model

Database table: AKModel_eventparticipant

A participant describes a person taking part in an event.

Parameters:
  • id (AutoField) – Primary key: ID

  • name (CharField) – Nickname. Name to identify a participant by (in case of questions from the organizers)

  • institution (CharField) – Institution. Uni etc.

Relationship fields:

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

  • requirements (ManyToManyField to AKRequirement) – Requirements. Participant’s Requirements (related name: eventparticipant)

Reverse relationships:

Parameters:
  • akpreference (Reverse ForeignKey from AKPreference) – All AK Preferences of this Participant (related name of participant)

  • availabilities (Reverse ForeignKey from Availability) – All availabilities of this Participant (related name of participant)

as_json_dict() dict[str, Any][source]

Return a json representation of this participant object.

Returns:

The json dict representation is constructed following the input specification of the KoMa conference optimizer, cf. https://github.com/Die-KoMa/ak-plan-optimierung/wiki/Input-&-output-format

Return type:

dict[str, Any]

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

Bases: Model

Database table: AKModel_akpreference

Model representing the preference of a participant to an AK.

Parameters:

Relationship fields:

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

  • participant (ForeignKey to EventParticipant) – Participant. Participant this preference belongs to (related name: akpreference)

  • slot (ForeignKey to AKSlot) – AK Slot. AK Slot this preference belongs to (related name: akpreference)

class PreferenceLevel(value)[source]

Bases: IntegerChoices

Possible preference values

as_json_dict() dict[str, int | bool][source]

Return a json representation of this AKPreference object.

Returns:

The json dict representation is constructed following the input specification of the KoMa conference optimizer, cf. https://github.com/Die-KoMa/ak-plan-optimierung/wiki/Input-&-output-format

Return type:

dict[str, Any]

class AKModel.models.HistoricalAK(id, name, short_name, description, link, protocol_link, reso, present, notes, category, track, event, history_id, history_date, history_change_reason, history_type, history_user)

Bases: HistoricalChanges, Model

Database table: AKModel_historicalak

Parameters:
  • id (IntegerField) – ID

  • name (CharField) – Name. Name of the AK

  • short_name (CharField) – Short Name. Name displayed in the schedule

  • description (TextField) – Description. Description of the AK

  • link (URLField) – Web Link. Link to wiki page

  • protocol_link (URLField) – Protocol Link. Link to protocol

  • reso (BooleanField) – Resolution Intention. Intends to submit a resolution

  • present (BooleanField) – Present this AK. Present results of this AK

  • notes (TextField) – Organizational Notes. Notes to organizers. These are public. For private notes, please use the button for private messages on the detail page of this AK (after creation/editing).

  • history_id (AutoField) – Primary key: History id

  • history_date (DateTimeField) – History date

  • history_change_reason (CharField) – History change reason

  • history_type (CharField) – History type

Relationship fields:

Parameters:
static get_default_history_user(instance)

Returns the user specified by get_user method for manually creating historical objects

instance_type

alias of AK

property next_record

Get the next history record for the instance. None if last.

property prev_record

Get the previous history record for the instance. None if first.

revert_url()

URL for this change in the default admin site.