AKModel.models module
- class AKModel.models.OptimizerTimeslot(avail: Availability, idx: int, constraints: set[str])[source]
Bases:
objectClass describing a discrete timeslot. Used to interface with an optimizer.
- avail: Availability
The availability object corresponding to this timeslot.
- 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.
- 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:
ModelDatabase table:
AKModel_eventAn 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/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
poll_hidden (BooleanField) – Poll Hidden. Hides preference poll for non-staff users
poll_published_at (DateTimeField) – Poll published at. Timestamp at which the preference poll 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
ForeignKeyfromAKOwner) – All AK Owners of this Event (related name ofevent)akcategory (Reverse
ForeignKeyfromAKCategory) – All AK Categories of this Event (related name ofevent)aktrack (Reverse
ForeignKeyfromAKTrack) – All AK Tracks of this Event (related name ofevent)akrequirement (Reverse
ForeignKeyfromAKRequirement) – All AK Requirements of this Event (related name ofevent)aktype (Reverse
ForeignKeyfromAKType) – All AK Types of this Event (related name ofevent)ak (Reverse
ForeignKeyfromAK) – All AKs of this Event (related name ofevent)room (Reverse
ForeignKeyfromRoom) – All Rooms of this Event (related name ofevent)akslot (Reverse
ForeignKeyfromAKSlot) – All AK Slots of this Event (related name ofevent)akorgamessage (Reverse
ForeignKeyfromAKOrgaMessage) – All AK Orga Messages of this Event (related name ofevent)constraintviolation (Reverse
ForeignKeyfromConstraintViolation) – All Constraint Violations of this Event (related name ofevent)defaultslot (Reverse
ForeignKeyfromDefaultSlot) – All Default Slots of this Event (related name ofevent)availabilities (Reverse
ForeignKeyfromAvailability) – All availabilities of this Event (related name ofevent)dashboardbutton (Reverse
ForeignKeyfromDashboardButton) – All Dashboard Buttons of this Event (related name ofevent)eventparticipant (Reverse
ForeignKeyfromEventParticipant) – All Participants of this Event (related name ofevent)akpreference (Reverse
ForeignKeyfromAKPreference) – All AK Preferences of this Event (related name ofevent)
- 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:
- 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, types=None, types_all_selected_only=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
hide_empty_categories (bool) – If True, categories with no AKs will not be included in the result
types (list[AKType] | None) – Optional list of AK types to filter by, if None, all types are included
types_all_selected_only (bool) – If True, only include AKs that have all of the selected types at the same time
- Returns:
list of category-AK-list-tuples, optionally the additional list of AK wishes
- Return type:
- 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
- property rooms
Ordered queryset of all rooms associated to this event.
- property slots
Ordered queryset of all AKSlots associated to this event.
- property participants
Ordered queryset of all participants associated to this event.
- property owners
Ordered queryset of all AK owners associated to this event.
- class AKModel.models.AKOwner(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_akownerAn AKOwner describes the person organizing/holding an AK.
- Parameters:
Relationship fields:
- Parameters:
event (
ForeignKeytoEvent) – Event. Associated event (related name:akowner)
Reverse relationships:
- Parameters:
ak (Reverse
ManyToManyFieldfromAK) – All AKs of this AK Owner (related name ofowners)constraintviolation (Reverse
ForeignKeyfromConstraintViolation) – All Constraint Violations of this AK Owner (related name ofak_owner)availabilities (Reverse
ForeignKeyfromAvailability) – All availabilities of this AK Owner (related name ofperson)
- class AKModel.models.AKCategory(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_akcategoryAn 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 (
ForeignKeytoEvent) – Event. Associated event (related name:akcategory)
Reverse relationships:
- Parameters:
ak (Reverse
ForeignKeyfromAK) – All AKs of this AK Category (related name ofcategory)constraintviolation (Reverse
ForeignKeyfromConstraintViolation) – All Constraint Violations of this AK Category (related name ofcategory)defaultslot (Reverse
ManyToManyFieldfromDefaultSlot) – All Default Slots of this AK Category (related name ofprimary_categories)availabilities (Reverse
ForeignKeyfromAvailability) – All availabilities of this AK Category (related name ofak_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:
ModelDatabase table:
AKModel_aktrackAn AKTrack describes a set of semantically related AKs.
- Parameters:
Relationship fields:
- Parameters:
event (
ForeignKeytoEvent) – Event. Associated event (related name:aktrack)
Reverse relationships:
- Parameters:
ak (Reverse
ForeignKeyfromAK) – All AKs of this AK Track (related name oftrack)
- class AKModel.models.AKRequirement(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_akrequirementAn AKRequirement describes something needed to hold an AK, e.g. infrastructure.
- Parameters:
id (AutoField) – Primary key: ID
name (CharField) – Name. Name of the Requirement
relevant_for_participants (BooleanField) – Relevant for Participants?. Show this requirement when collecting participant preferences
Relationship fields:
- Parameters:
event (
ForeignKeytoEvent) – Event. Associated event (related name:akrequirement)
Reverse relationships:
- Parameters:
ak (Reverse
ManyToManyFieldfromAK) – All AKs of this AK Requirement (related name ofrequirements)room (Reverse
ManyToManyFieldfromRoom) – All Rooms of this AK Requirement (related name ofproperties)constraintviolation (Reverse
ForeignKeyfromConstraintViolation) – All Constraint Violations of this AK Requirement (related name ofrequirement)eventparticipant (Reverse
ManyToManyFieldfromEventParticipant) – All Participants of this AK Requirement (related name ofrequirements)
- class AKModel.models.AKType(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_aktypeAn 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 (
ForeignKeytoEvent) – Event. Associated event (related name:aktype)
Reverse relationships:
- Parameters:
ak (Reverse
ManyToManyFieldfromAK) – All AKs of this AK Type (related name oftypes)
- class AKModel.models.AK(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_akAn 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) – Brief Description. 1-2 sentences of AK description
goal (CharField) – Design/Goal. Design of the AK (e.g. discussion, problem solving, brainstorming, input, output) and/or goal (e.g. Reso, solution, collection of ideas, document, exchange) in a few words
info (TextField) – Further Information. Anything else about the AK, e.g. links, stories, detailed description
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 (
ForeignKeytoAKCategory) – Category. Category of the AK (related name:ak)track (
ForeignKeytoAKTrack) – Track. Track the AK belongs to (related name:ak)event (
ForeignKeytoEvent) – Event. Associated event (related name:ak)owners (
ManyToManyFieldtoAKOwner) – Owners. Those organizing the AK (related name:ak)types (
ManyToManyFieldtoAKType) – Types. This AK is (related name:ak)requirements (
ManyToManyFieldtoAKRequirement) – Requirements. AK’s Requirements (related name:ak)conflicts (
ManyToManyFieldtoAK) – Conflicting AKs. AKs that conflict and thus must not take place at the same time (related name:conflict)prerequisites (
ManyToManyFieldtoAK) – Prerequisite AKs. AKs that should precede this AK in the schedule (related name:ak)
Reverse relationships:
- Parameters:
conflict (Reverse
ManyToManyFieldfromAK) – All conflict of this AK (related name ofconflicts)ak (Reverse
ManyToManyFieldfromAK) – All AKs of this AK (related name ofprerequisites)akslot (Reverse
ForeignKeyfromAKSlot) – All AK Slots of this AK (related name ofak)akorgamessage (Reverse
ForeignKeyfromAKOrgaMessage) – All AK Orga Messages of this AK (related name ofak)constraintviolation (Reverse
ManyToManyFieldfromConstraintViolation) – All Constraint Violations of this AK (related name ofaks)availabilities (Reverse
ForeignKeyfromAvailability) – All availabilities of this AK (related name ofak)akpreference (Reverse
ForeignKeyfromAKPreference) – All AK Preferences of this AK (related name ofak)
- 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 stringified list of stringified representations of all owners
- Returns:
stringified list of owners
- Return type:
- property durations_list
Get a stringified list of stringified representations of all durations of associated slots
- Returns:
stringified list of durations
- Return type:
- property types_list
Get a stringified list of all types of this AK
- Returns:
stringified list of types
- Return type:
- 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:
- 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:
- 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:
ModelDatabase table:
AKModel_roomA 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:
event (
ForeignKeytoEvent) – Event. Associated event (related name:room)properties (
ManyToManyFieldtoAKRequirement) – Properties. AK requirements fulfilled by the room (related name:room)
Reverse relationships:
- Parameters:
akslot (Reverse
ForeignKeyfromAKSlot) – All AK Slots of this Room (related name ofroom)constraintviolation (Reverse
ForeignKeyfromConstraintViolation) – All Constraint Violations of this Room (related name ofroom)availabilities (Reverse
ForeignKeyfromAvailability) – All availabilities of this Room (related name ofroom)virtual (Reverse
OneToOneFieldfromVirtualRoom) – The virtual of this Room (related name ofroom)
- 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:
- class AKModel.models.AKSlot(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_akslotAn AK Mapping matches an AK to a room during a certain time.
- Parameters:
id (AutoField) – Primary key: ID
start (DateTimeField) – Slot Begin. Time and date the slot begins
duration (DecimalField) – Duration. Length in hours
fixed (BooleanField) – Scheduling fixed. Length and time of this AK should not be changed
updated (DateTimeField) – Last update
Relationship fields:
- Parameters:
ak (
ForeignKeytoAK) – AK. AK being mapped (related name:akslot)room (
ForeignKeytoRoom) – Room. Room the AK will take place in (related name:akslot)event (
ForeignKeytoEvent) – Event. Associated event (related name:akslot)
Reverse relationships:
- Parameters:
constraintviolation (Reverse
ManyToManyFieldfromConstraintViolation) – All Constraint Violations of this AK Slot (related name ofak_slots)
- 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:
- get_room_constraints(export_scheduled_aks_as_fixed: bool = False) list[str][source]
Construct list of required room constraint labels.
- get_time_constraints(export_scheduled_aks_as_fixed: bool = False) list[str][source]
Construct list of required time constraint labels.
- property type_names
Ordered queryset of the names of all types of this slot’s AK.
- class AKModel.models.AKOrgaMessage(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_akorgamessageModel 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 (
ForeignKeytoAK) – AK. AK this message belongs to (related name:akorgamessage)event (
ForeignKeytoEvent) – Event. Associated event (related name:akorgamessage)
- class AKModel.models.ConstraintViolation(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_constraintviolationModel to represent any kind of constraint violation
Can have two different severities: violation and warning The list of possible types is defined in
ViolationTypeDepending 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 (
ForeignKeytoEvent) – Event. Associated event (related name:constraintviolation)ak_owner (
ForeignKeytoAKOwner) – AK Owner. AK Owner belonging to this constraint (related name:constraintviolation)room (
ForeignKeytoRoom) – Room. Room belonging to this constraint (related name:constraintviolation)requirement (
ForeignKeytoAKRequirement) – AK Requirement. AK Requirement belonging to this constraint (related name:constraintviolation)category (
ForeignKeytoAKCategory) – AK Category. AK Category belonging to this constraint (related name:constraintviolation)aks (
ManyToManyFieldtoAK) – AKs. AK(s) belonging to this constraint (related name:constraintviolation)ak_slots (
ManyToManyFieldtoAKSlot) – AK Slots. AK Slot(s) belonging to this constraint (related name:constraintviolation)
- class ViolationType(value)[source]
Bases:
TextChoicesPossible types of violations with their text representation
- get_details()[source]
Get details of this constraint (all fields connected to it) :return: string of details :rtype: str
- property details
Property: Details
- 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:
- class AKModel.models.DefaultSlot(*args, **kwargs)[source]
Bases:
ModelDatabase table:
AKModel_defaultslotModel representing a default slot, i.e., a prefered slot to use for typical AKs in the schedule to guarantee enough breaks etc.
- Parameters:
id (AutoField) – Primary key: ID
start (DateTimeField) – Slot Begin. Time and date the slot begins
end (DateTimeField) – Slot End. Time and date the slot ends
Relationship fields:
- Parameters:
event (
ForeignKeytoEvent) – Event. Associated event (related name:defaultslot)primary_categories (
ManyToManyFieldtoAKCategory) – 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
- class AKModel.models.HistoricalAK(id, name, short_name, description, goal, info, link, protocol_link, reso, present, notes, category, track, event, history_id, history_date, history_change_reason, history_type, history_user)
Bases:
HistoricalChanges,ModelDatabase 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) – Brief Description. 1-2 sentences of AK description
goal (CharField) – Design/Goal. Design of the AK (e.g. discussion, problem solving, brainstorming, input, output) and/or goal (e.g. Reso, solution, collection of ideas, document, exchange) in a few words
info (TextField) – Further Information. Anything else about the AK, e.g. links, stories, detailed description
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:
category (
ForeignKeytoAKCategory) – Category. Category of the AK (related name:+)track (
ForeignKeytoAKTrack) – Track. Track the AK belongs to (related name:+)event (
ForeignKeytoEvent) – Event. Associated event (related name:+)history_user (
ForeignKeytoUser) – History user (related name:+)
- static get_default_history_user(instance)
Returns the user specified by get_user method for manually creating historical objects
- 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.