Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • feature-type-filters
  • komasolver
  • main
  • renovate/django-5.x
  • renovate/django_csp-4.x
  • renovate/jsonschema-4.x
  • renovate/uwsgi-2.x
7 results

Target

Select target project
  • konstantin/akplanning
  • matedealer/akplanning
  • kif/akplanning
  • mirco/akplanning
  • lordofthevoid/akplanning
  • voidptr/akplanning
  • xayomer/akplanning-fork
  • mollux/akplanning
  • neumantm/akplanning
  • mmarx/akplanning
  • nerf/akplanning
  • felix_bonn/akplanning
  • sebastian.uschmann/akplanning
13 results
Select Git revision
  • ak-import
  • feature/clear-schedule-button
  • feature/json-export-via-rest-framework
  • feature/json-schedule-import-tests
  • feature/preference-polling-form
  • fix/add-room-import-only-once
  • main
  • renovate/django-5.x
  • renovate/django-debug-toolbar-4.x
  • renovate/django-simple-history-3.x
  • renovate/mysqlclient-2.x
11 results
Show changes
Commits on Source (177)
Showing
with 1739 additions and 308 deletions
uwsgi==2.0.25.1
uwsgi==2.0.29
image: python:3.9
image: python:3.11
services:
- mysql
......@@ -26,10 +26,9 @@ cache:
- pip install pylint-gitlab pylint-django
- mysql --version
check:
migrations:
extends: .before_script_template
script:
- ./Utils/check.sh --all
- source venv/bin/activate
- ./manage.py makemigrations --dry-run --check
......@@ -38,7 +37,7 @@ test:
script:
- source venv/bin/activate
- echo "GRANT ALL on *.* to '${MYSQL_USER}';"| mysql -u root --password="${MYSQL_ROOT_PASSWORD}" -h mysql
- pip install pytest-cov unittest-xml-reporting
- pip install pytest-cov
- coverage run --source='.' manage.py test --settings AKPlanning.settings_ci
after_script:
- source venv/bin/activate
......
import zoneinfo
from django.apps import apps
from django.test import TestCase, override_settings
from django.test import override_settings, TestCase
from django.urls import reverse
from django.utils.timezone import now
from AKDashboard.models import DashboardButton
from AKModel.models import Event, AK, AKCategory
from AKModel.tests import BasicViewTests
from AKModel.models import AK, AKCategory, Event
from AKModel.tests.test_views import BasicViewTests
class DashboardTests(TestCase):
"""
Specific Dashboard Tests
"""
@classmethod
def setUpTestData(cls):
"""
......@@ -20,17 +22,17 @@ class DashboardTests(TestCase):
"""
super().setUpTestData()
cls.event = Event.objects.create(
name="Dashboard Test Event",
slug="dashboardtest",
timezone=zoneinfo.ZoneInfo("Europe/Berlin"),
start=now(),
end=now(),
active=True,
plan_hidden=False,
name="Dashboard Test Event",
slug="dashboardtest",
timezone=zoneinfo.ZoneInfo("Europe/Berlin"),
start=now(),
end=now(),
active=True,
plan_hidden=False,
)
cls.default_category = AKCategory.objects.create(
name="Test Category",
event=cls.event,
name="Test Category",
event=cls.event,
)
def test_dashboard_view(self):
......@@ -62,12 +64,12 @@ class DashboardTests(TestCase):
# History should be empty
response = self.client.get(url)
self.assertQuerysetEqual(response.context["recent_changes"], [])
self.assertQuerySetEqual(response.context["recent_changes"], [])
AK.objects.create(
name="Test AK",
category=self.default_category,
event=self.event,
name="Test AK",
category=self.default_category,
event=self.event,
)
# History should now contain one AK (Test AK)
......@@ -154,8 +156,8 @@ class DashboardTests(TestCase):
self.assertNotContains(response, "Dashboard Button Test")
DashboardButton.objects.create(
text="Dashboard Button Test",
event=self.event
text="Dashboard Button Test",
event=self.event
)
response = self.client.get(url_event_dashboard)
......
......@@ -17,7 +17,7 @@ from simple_history.admin import SimpleHistoryAdmin
from AKModel.availability.models import Availability
from AKModel.forms import RoomFormWithAvailabilities
from AKModel.models import Event, AKOwner, AKCategory, AKTrack, AKRequirement, AK, AKSlot, Room, AKOrgaMessage, \
ConstraintViolation, DefaultSlot, AKType
ConstraintViolation, DefaultSlot, AKType, EventParticipant, AKPreference
from AKModel.urls import get_admin_urls_event_wizard, get_admin_urls_event
from AKModel.views.ak import AKResetInterestView, AKResetInterestCounterView
from AKModel.views.manage import CVMarkResolvedView, CVSetLevelViolationView, CVSetLevelWarningView
......@@ -81,6 +81,10 @@ class EventAdmin(admin.ModelAdmin):
from AKScheduling.urls import get_admin_urls_scheduling # pylint: disable=import-outside-toplevel
urls.extend(get_admin_urls_scheduling(self.admin_site))
if apps.is_installed("AKSolverInterface"):
from AKSolverInterface.urls import get_admin_urls_solver_interface # pylint: disable=import-outside-toplevel
urls.extend(get_admin_urls_solver_interface(self.admin_site))
# Make sure built-in URLs are available as well
urls.extend(super().get_urls())
return urls
......@@ -572,6 +576,50 @@ class DefaultSlotAdmin(EventTimezoneFormMixin, admin.ModelAdmin):
form = DefaultSlotAdminForm
@admin.register(EventParticipant)
class EventParticipantAdmin(PrepopulateWithNextActiveEventMixin, admin.ModelAdmin):
"""
Admin interface for EventParticipant
"""
model = EventParticipant
list_display = ['name', 'institution', 'event']
list_filter = ['event', 'institution']
list_editable = []
ordering = ['name']
class AKPreferenceAdminForm(forms.ModelForm):
"""
Adapted admin form for AK preferences for usage in :class:`AKPreferenceAdmin`)
"""
class Meta:
widgets = {
'participant': forms.Select,
'slot': forms.Select,
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Filter possible values for foreign keys & m2m when event is specified
if hasattr(self.instance, "event") and self.instance.event is not None:
self.fields["participant"].queryset = EventParticipant.objects.filter(event=self.instance.event)
self.fields["slot"].queryset = AKSlot.objects.filter(event=self.instance.event)
@admin.register(AKPreference)
class AKPreferenceAdmin(PrepopulateWithNextActiveEventMixin, admin.ModelAdmin):
"""
Admin interface for AK preferences.
Uses an adapted form (see :class:`AKPreferenceAdminForm`)
"""
model = AKPreference
form = AKPreferenceAdminForm
list_display = ['preference', 'participant', 'slot', 'event']
list_filter = ['event', 'slot', 'participant']
list_editable = []
ordering = ['participant', 'preference', 'slot']
# Define a new User admin
class UserAdmin(BaseUserAdmin):
"""
......
......@@ -183,7 +183,7 @@ class AvailabilitiesFormMixin(forms.Form):
for avail in availabilities:
setattr(avail, reference_name, instance.id)
def _replace_availabilities(self, instance, availabilities: [Availability]):
def _replace_availabilities(self, instance, availabilities: list[Availability]):
"""
Replace the existing list of availabilities belonging to an entity with a new, updated one
......
......@@ -10,7 +10,7 @@ from django.db import models
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from AKModel.models import Event, AKOwner, Room, AK, AKCategory
from AKModel.models import Event, AKOwner, Room, AK, AKCategory, EventParticipant
zero_time = datetime.time(0, 0)
......@@ -24,6 +24,7 @@ zero_time = datetime.time(0, 0)
# enable availabilities for AKs and AKCategories
# add verbose names and help texts to model attributes
# adapt or extemd documentation
# add participants
class Availability(models.Model):
......@@ -79,20 +80,48 @@ class Availability(models.Model):
verbose_name=_('AK Category'),
help_text=_('AK Category whose availability this is'),
)
participant = models.ForeignKey(
to=EventParticipant,
related_name='availabilities',
on_delete=models.CASCADE,
null=True,
blank=True,
verbose_name=_('Participant'),
help_text=_('Participant whose availability this is'),
)
start = models.DateTimeField()
end = models.DateTimeField()
def __str__(self) -> str:
person = self.person.name if self.person else None
participant = self.participant.name if self.participant else None
room = getattr(self.room, 'name', None)
event = getattr(getattr(self, 'event', None), 'name', None)
ak = getattr(self.ak, 'name', None)
ak_category = getattr(self.ak_category, 'name', None)
return f'Availability(event={event}, person={person}, room={room}, ak={ak}, ak category={ak_category})'
arg_list = [
f"event={event}",
f"person={person}",
f"room={room}",
f"ak={ak}",
f"ak category={ak_category}",
f"participant={participant}",
]
return f'Availability({", ".join(arg_list)})'
def __hash__(self):
return hash(
(getattr(self, 'event', None), self.person, self.room, self.ak, self.ak_category, self.start, self.end))
(
getattr(self, 'event', None),
self.person,
self.room,
self.ak,
self.ak_category,
self.participant,
self.start,
self.end,
)
)
def __eq__(self, other: 'Availability') -> bool:
"""Comparisons like ``availability1 == availability2``.
......@@ -103,7 +132,7 @@ class Availability(models.Model):
return all(
(
getattr(self, attribute, None) == getattr(other, attribute, None)
for attribute in ['event', 'person', 'room', 'ak', 'ak_category', 'start', 'end']
for attribute in ['event', 'person', 'room', 'ak', 'ak_category', 'participant', 'start', 'end']
)
)
......@@ -151,9 +180,12 @@ class Availability(models.Model):
if not other.overlaps(self, strict=False):
raise Exception('Only overlapping Availabilities can be merged.')
return Availability(
avail = Availability(
start=min(self.start, other.start), end=max(self.end, other.end)
)
if self.event == other.event:
avail.event = self.event
return avail
def __or__(self, other: 'Availability') -> 'Availability':
"""Performs the merge operation: ``availability1 | availability2``"""
......@@ -168,9 +200,12 @@ class Availability(models.Model):
if not other.overlaps(self, False):
raise Exception('Only overlapping Availabilities can be intersected.')
return Availability(
avail = Availability(
start=max(self.start, other.start), end=min(self.end, other.end)
)
if self.event == other.event:
avail.event = self.event
return avail
def __and__(self, other: 'Availability') -> 'Availability':
"""Performs the intersect operation: ``availability1 &
......@@ -247,7 +282,15 @@ class Availability(models.Model):
f'{self.end.astimezone(self.event.timezone).strftime("%a %H:%M")}')
@classmethod
def with_event_length(cls, event, person=None, room=None, ak=None, ak_category=None):
def with_event_length(
cls,
event: Event,
person: AKOwner | None = None,
room: Room | None = None,
ak: AK | None = None,
ak_category: AKCategory | None = None,
participant: EventParticipant | None = None,
) -> "Availability":
"""
Create an availability covering exactly the time between event start and event end.
Can e.g., be used to create default availabilities.
......@@ -265,7 +308,31 @@ class Availability(models.Model):
timeframe_end = event.end # adapt to our event model
timeframe_end = timeframe_end + datetime.timedelta(days=1)
return Availability(start=timeframe_start, end=timeframe_end, event=event, person=person,
room=room, ak=ak, ak_category=ak_category)
room=room, ak=ak, ak_category=ak_category, participant=participant)
def is_covered(self, availabilities: List['Availability']):
"""Check if list of availibilities cover this object.
:param availabilities: availabilities to check.
:return: whether the availabilities cover full event.
:rtype: bool
"""
avail_union = Availability.union(availabilities)
return any(avail.contains(self) for avail in avail_union)
@classmethod
def is_event_covered(cls, event: Event, availabilities: List['Availability']) -> bool:
"""Check if list of availibilities cover whole event.
:param event: event to check.
:param availabilities: availabilities to check.
:return: whether the availabilities cover full event.
:rtype: bool
"""
# NOTE: Cannot use `Availability.with_event_length` as its end is the
# event end + 1 day
full_event = Availability(event=event, start=event.start, end=event.end)
return full_event.is_covered(availabilities)
class Meta:
verbose_name = _('Availability')
......
......@@ -93,7 +93,7 @@
"model": "AKModel.akcategory",
"pk": 1,
"fields": {
"name": "Spa",
"name": "Spaß",
"color": "275246",
"description": "",
"present_by_default": true,
......@@ -115,7 +115,7 @@
"model": "AKModel.akcategory",
"pk": 3,
"fields": {
"name": "Spa/Kultur",
"name": "Spaß/Kultur",
"color": "333333",
"description": "",
"present_by_default": true,
......@@ -437,6 +437,62 @@
]
}
},
{
"model": "AKModel.ak",
"pk": 4,
"fields": {
"name": "Test AK fixed slots",
"short_name": "testfixed",
"description": "",
"link": "",
"protocol_link": "",
"category": 4,
"track": null,
"reso": false,
"present": true,
"notes": "",
"interest": -1,
"interest_counter": 0,
"include_in_export": false,
"event": 2,
"owners": [
1
],
"requirements": [
3
],
"conflicts": [],
"prerequisites": []
}
},
{
"model": "AKModel.ak",
"pk": 5,
"fields": {
"name": "Test AK Ernst",
"short_name": "testernst",
"description": "",
"link": "",
"protocol_link": "",
"category": 2,
"track": null,
"reso": false,
"present": true,
"notes": "",
"interest": -1,
"interest_counter": 0,
"include_in_export": false,
"event": 1,
"owners": [
3
],
"requirements": [
2
],
"conflicts": [],
"prerequisites": []
}
},
{
"model": "AKModel.room",
"pk": 1,
......@@ -461,6 +517,19 @@
"properties": []
}
},
{
"model": "AKModel.room",
"pk": 3,
"fields": {
"name": "BBB Session 1",
"location": "",
"capacity": -1,
"event": 1,
"properties": [
2
]
}
},
{
"model": "AKModel.akslot",
"pk": 1,
......@@ -526,6 +595,58 @@
"updated": "2022-12-02T12:23:11.856Z"
}
},
{
"model": "AKModel.akslot",
"pk": 6,
"fields": {
"ak": 4,
"room": null,
"start": "2020-11-08T18:30:00Z",
"duration": "2.00",
"fixed": true,
"event": 2,
"updated": "2022-12-02T12:23:11.856Z"
}
},
{
"model": "AKModel.akslot",
"pk": 7,
"fields": {
"ak": 4,
"room": 2,
"start": null,
"duration": "2.00",
"fixed": true,
"event": 2,
"updated": "2022-12-02T12:23:11.856Z"
}
},
{
"model": "AKModel.akslot",
"pk": 8,
"fields": {
"ak": 4,
"room": 2,
"start": "2020-11-07T16:00:00Z",
"duration": "2.00",
"fixed": true,
"event": 2,
"updated": "2022-12-02T12:23:11.856Z"
}
},
{
"model": "AKModel.akslot",
"pk": 9,
"fields": {
"ak": 5,
"room": null,
"start": null,
"duration": "2.00",
"fixed": false,
"event": 1,
"updated": "2022-12-02T12:23:11.856Z"
}
},
{
"model": "AKModel.constraintviolation",
"pk": 1,
......@@ -669,5 +790,71 @@
"start": "2020-11-07T18:30:00Z",
"end": "2020-11-07T21:30:00Z"
}
},
{
"model": "AKModel.availability",
"pk": 7,
"fields": {
"event": 1,
"person": null,
"room": null,
"ak": 5,
"ak_category": null,
"start": "2020-10-01T17:41:22Z",
"end": "2020-10-04T17:41:30Z"
}
},
{
"model": "AKModel.availability",
"pk": 8,
"fields": {
"event": 1,
"person": null,
"room": 3,
"ak": null,
"ak_category": null,
"start": "2020-10-01T17:41:22Z",
"end": "2020-10-04T17:41:30Z"
}
},
{
"model": "AKModel.defaultslot",
"pk": 1,
"fields": {
"event": 2,
"start": "2020-11-07T08:00:00Z",
"end": "2020-11-07T12:00:00Z",
"primary_categories": [5]
}
},
{
"model": "AKModel.defaultslot",
"pk": 2,
"fields": {
"event": 2,
"start": "2020-11-07T14:00:00Z",
"end": "2020-11-07T17:00:00Z",
"primary_categories": [4]
}
},
{
"model": "AKModel.defaultslot",
"pk": 3,
"fields": {
"event": 2,
"start": "2020-11-08T08:00:00Z",
"end": "2020-11-08T19:00:00Z",
"primary_categories": [4, 5]
}
},
{
"model": "AKModel.defaultslot",
"pk": 4,
"fields": {
"event": 2,
"start": "2020-11-09T17:00:00Z",
"end": "2020-11-10T01:00:00Z",
"primary_categories": [4, 5, 3]
}
}
]
......@@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-26 16:35+0100\n"
"POT-Creation-Date: 2025-03-03 20:47+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -33,7 +33,7 @@ msgstr "Plan veröffentlichen"
msgid "Unpublish plan"
msgstr "Plan verbergen"
#: AKModel/admin.py:170 AKModel/models.py:381 AKModel/models.py:707
#: AKModel/admin.py:170 AKModel/models.py:396 AKModel/models.py:736
#: AKModel/templates/admin/AKModel/aks_by_user.html:12
#: AKModel/templates/admin/AKModel/status/event_aks.html:10
#: AKModel/views/manage.py:73 AKModel/views/status.py:102
......@@ -84,19 +84,19 @@ msgstr "Constraintverletzungen auf Level \"Violation\" setzen"
msgid "Set Constraint Violations to level \"warning\""
msgstr "Constraintverletzungen auf Level \"Warning\" setzen"
#: AKModel/admin.py:580
#: AKModel/admin.py:585
msgid "Activate selected users"
msgstr "Ausgewählte Benutzer*innen aktivieren"
#: AKModel/admin.py:583
#: AKModel/admin.py:594
msgid "The selected users have been activated."
msgstr "Benutzer*innen aktiviert"
#: AKModel/admin.py:585
#: AKModel/admin.py:596
msgid "Deactivate selected users"
msgstr "Ausgewählte Benutzer*innen deaktivieren"
#: AKModel/admin.py:588
#: AKModel/admin.py:605
msgid "The selected users have been deactivated."
msgstr "Benutzer*innen deaktiviert"
......@@ -125,19 +125,19 @@ msgstr "Die eingegebene Verfügbarkeit enthält ein ungültiges Datum."
msgid "Please fill in your availabilities!"
msgstr "Bitte Verfügbarkeiten eintragen!"
#: AKModel/availability/models.py:43 AKModel/models.py:60 AKModel/models.py:174
#: AKModel/models.py:251 AKModel/models.py:270 AKModel/models.py:296
#: AKModel/models.py:315 AKModel/models.py:371 AKModel/models.py:517
#: AKModel/models.py:556 AKModel/models.py:646 AKModel/models.py:703
#: AKModel/models.py:894
#: AKModel/availability/models.py:43 AKModel/models.py:71 AKModel/models.py:187
#: AKModel/models.py:264 AKModel/models.py:283 AKModel/models.py:309
#: AKModel/models.py:328 AKModel/models.py:386 AKModel/models.py:546
#: AKModel/models.py:585 AKModel/models.py:675 AKModel/models.py:732
#: AKModel/models.py:923
msgid "Event"
msgstr "Event"
#: AKModel/availability/models.py:44 AKModel/models.py:175
#: AKModel/models.py:252 AKModel/models.py:271 AKModel/models.py:297
#: AKModel/models.py:316 AKModel/models.py:372 AKModel/models.py:518
#: AKModel/models.py:557 AKModel/models.py:647 AKModel/models.py:704
#: AKModel/models.py:895
#: AKModel/availability/models.py:44 AKModel/models.py:188
#: AKModel/models.py:265 AKModel/models.py:284 AKModel/models.py:310
#: AKModel/models.py:329 AKModel/models.py:387 AKModel/models.py:547
#: AKModel/models.py:586 AKModel/models.py:676 AKModel/models.py:733
#: AKModel/models.py:924
msgid "Associated event"
msgstr "Zugehöriges Event"
......@@ -149,8 +149,8 @@ msgstr "Person"
msgid "Person whose availability this is"
msgstr "Person deren Verfügbarkeit hier abgebildet wird"
#: AKModel/availability/models.py:61 AKModel/models.py:521
#: AKModel/models.py:546 AKModel/models.py:713
#: AKModel/availability/models.py:61 AKModel/models.py:550
#: AKModel/models.py:575 AKModel/models.py:742
msgid "Room"
msgstr "Raum"
......@@ -158,8 +158,8 @@ msgstr "Raum"
msgid "Room whose availability this is"
msgstr "Raum dessen Verfügbarkeit hier abgebildet wird"
#: AKModel/availability/models.py:70 AKModel/models.py:380
#: AKModel/models.py:545 AKModel/models.py:641
#: AKModel/availability/models.py:70 AKModel/models.py:395
#: AKModel/models.py:574 AKModel/models.py:670
msgid "AK"
msgstr "AK"
......@@ -167,8 +167,8 @@ msgstr "AK"
msgid "AK whose availability this is"
msgstr "Verfügbarkeiten"
#: AKModel/availability/models.py:79 AKModel/models.py:255
#: AKModel/models.py:719
#: AKModel/availability/models.py:79 AKModel/models.py:268
#: AKModel/models.py:748
msgid "AK Category"
msgstr "AK-Kategorie"
......@@ -242,7 +242,7 @@ msgstr ""
"fürWünsche markieren, z.B. um während der Präsentation auf einem Touchscreen "
"ausgefüllt zu werden?"
#: AKModel/forms.py:198 AKModel/models.py:888
#: AKModel/forms.py:198 AKModel/models.py:917
msgid "Default Slots"
msgstr "Standardslots"
......@@ -281,7 +281,7 @@ msgstr "Standardverfügbarkeiten für alle Räume anlegen?"
msgid "CSV must contain a name column"
msgstr "CSV muss eine name-Spalte enthalten"
#: AKModel/metaviews/admin.py:156 AKModel/models.py:29
#: AKModel/metaviews/admin.py:156 AKModel/models.py:40
msgid "Start"
msgstr "Start"
......@@ -306,67 +306,75 @@ msgstr "Aktivieren?"
msgid "Finish"
msgstr "Abschluss"
#: AKModel/models.py:20 AKModel/models.py:243 AKModel/models.py:267
#: AKModel/models.py:294 AKModel/models.py:313 AKModel/models.py:331
#: AKModel/models.py:507
#: AKModel/models.py:21
msgid "May not contain quotation marks"
msgstr "Darf keine Anführungszeichen enthalten"
#: AKModel/models.py:24
msgid "Must contain at least one letter or digit"
msgstr "Muss mindestens einen Buchstaben oder eine Ziffer enthalten"
#: AKModel/models.py:31 AKModel/models.py:256 AKModel/models.py:280
#: AKModel/models.py:307 AKModel/models.py:326 AKModel/models.py:344
#: AKModel/models.py:536
msgid "Name"
msgstr "Name"
#: AKModel/models.py:21
#: AKModel/models.py:32
msgid "Name or iteration of the event"
msgstr "Name oder Iteration des Events"
#: AKModel/models.py:22
#: AKModel/models.py:33
msgid "Short Form"
msgstr "Kurzer Name"
#: AKModel/models.py:23
#: AKModel/models.py:34
msgid "Short name of letters/numbers/dots/dashes/underscores used in URLs."
msgstr ""
"Kurzname bestehend aus Buchstaben, Nummern, Punkten und Unterstrichen zur "
"Nutzung in URLs"
#: AKModel/models.py:25
#: AKModel/models.py:36
msgid "Place"
msgstr "Ort"
#: AKModel/models.py:26
#: AKModel/models.py:37
msgid "City etc. the event takes place in"
msgstr "Stadt o.ä. in der das Event stattfindet"
#: AKModel/models.py:28
#: AKModel/models.py:39
msgid "Time Zone"
msgstr "Zeitzone"
#: AKModel/models.py:28
#: AKModel/models.py:39
msgid "Time Zone where this event takes place in"
msgstr "Zeitzone in der das Event stattfindet"
#: AKModel/models.py:29
#: AKModel/models.py:40
msgid "Time the event begins"
msgstr "Zeit zu der das Event beginnt"
#: AKModel/models.py:30
#: AKModel/models.py:41
msgid "End"
msgstr "Ende"
#: AKModel/models.py:30
#: AKModel/models.py:41
msgid "Time the event ends"
msgstr "Zeit zu der das Event endet"
#: AKModel/models.py:31
#: AKModel/models.py:42
msgid "Resolution Deadline"
msgstr "Resolutionsdeadline"
#: AKModel/models.py:32
#: AKModel/models.py:43
msgid "When should AKs with intention to submit a resolution be done?"
msgstr "Wann sollen AKs mit Resolutionsabsicht stattgefunden haben?"
#: AKModel/models.py:34
#: AKModel/models.py:45
msgid "Interest Window Start"
msgstr "Beginn Interessensbekundung"
#: AKModel/models.py:36
#: AKModel/models.py:47
msgid ""
"Opening time for expression of interest. When left blank, no interest "
"indication will be possible."
......@@ -374,71 +382,83 @@ msgstr ""
"Öffnungszeitpunkt für die Angabe von Interesse an AKs.Wenn das Feld leer "
"bleibt, wird keine Abgabe von Interesse möglich sein."
#: AKModel/models.py:38
#: AKModel/models.py:49
msgid "Interest Window End"
msgstr "Ende Interessensbekundung"
#: AKModel/models.py:39
#: AKModel/models.py:50
msgid "Closing time for expression of interest."
msgstr "Öffnungszeitpunkt für die Angabe von Interesse an AKs."
#: AKModel/models.py:41
#: AKModel/models.py:52
msgid "Public event"
msgstr "Öffentliches Event"
#: AKModel/models.py:42
#: AKModel/models.py:53
msgid "Show this event on overview page."
msgstr "Zeige dieses Event auf der Übersichtseite an"
#: AKModel/models.py:44
#: AKModel/models.py:55
msgid "Active State"
msgstr "Aktiver Status"
#: AKModel/models.py:44
#: AKModel/models.py:55
msgid "Marks currently active events"
msgstr "Markiert aktuell aktive Events"
#: AKModel/models.py:45
#: AKModel/models.py:56
msgid "Plan Hidden"
msgstr "Plan verborgen"
#: AKModel/models.py:45
#: AKModel/models.py:56
msgid "Hides plan for non-staff users"
msgstr "Verbirgt den Plan für Nutzer*innen ohne erweiterte Rechte"
#: AKModel/models.py:47
#: AKModel/models.py:58
msgid "Plan published at"
msgstr "Plan veröffentlicht am/um"
#: AKModel/models.py:48
#: AKModel/models.py:59
msgid "Timestamp at which the plan was published"
msgstr "Zeitpunkt, zu dem der Plan veröffentlicht wurde"
#: AKModel/models.py:50
#: AKModel/models.py:61
msgid "Base URL"
msgstr "URL-Prefix"
#: AKModel/models.py:50
#: AKModel/models.py:61
msgid "Prefix for wiki link construction"
msgstr "Prefix für die automatische Generierung von Wiki-Links"
#: AKModel/models.py:51
#: AKModel/models.py:62
msgid "Wiki Export Template Name"
msgstr "Wiki-Export Templatename"
#: AKModel/models.py:52
#: AKModel/models.py:63
msgid "Default Slot Length"
msgstr "Standardslotlänge"
#: AKModel/models.py:53
#: AKModel/models.py:64
msgid "Default length in hours that is assumed for AKs in this event."
msgstr "Standardlänge von Slots (in Stunden) für dieses Event"
#: AKModel/models.py:55
#: AKModel/models.py:154
msgid "Export Slot Length"
msgstr "Export-Slotlänge"
#: AKModel/models.py:156
msgid ""
"Slot duration in hours that is used in the timeslot discretization, when "
"this event is exported for the solver."
msgstr ""
"Länge von Slots (in Stunden) in der Zeitslot-Diskretisierung beim "
"JSON-Export dieses Events."
#: AKModel/models.py:161
msgid "Contact email address"
msgstr "E-Mail Kontaktadresse"
#: AKModel/models.py:56
#: AKModel/models.py:67
msgid ""
"An email address that is displayed on every page and can be used for all "
"kinds of questions"
......@@ -446,75 +466,115 @@ msgstr ""
"Eine Mailadresse die auf jeder Seite angezeigt wird und für alle Arten von "
"Fragen genutzt werden kann"
#: AKModel/models.py:61
#: AKModel/models.py:72
msgid "Events"
msgstr "Events"
#: AKModel/models.py:169
#: AKModel/models.py:427
msgid "Cannot parse malformed JSON input."
msgstr "Kann fehlerhafte JSON-Eingabe nicht verarbeiten"
#: AKModel/models.py:430
msgid "Data has changed since the export. Reexport and run the solver again."
msgstr "Seit dem Export wurden die Daten verändert. Wiederhole den Export und führe den Solver erneut aus."
#: AKModel/models.py:430
#, python-brace-format
msgid "AK {ak_name} is not assigned any timeslot by the solver"
msgstr "Dem AK {ak_name} wurde vom Solver kein Zeitslot zugewiesen"
#: AKModel/models.py:440
#, python-brace-format
msgid ""
"Duration of AK {ak_name} assigned by solver ({solver_duration} hours) is "
"less than the duration required by the slot ({slot_duration} hours)"
msgstr ""
"Die dem AK {ak_name} vom Solver zugewiesene Dauer ({solver_duration} Stunden) ist "
"kürzer als die aktuell vorgesehene Dauer des Slots ({slot_duration} Stunden)"
#: AKModel/models.py:454
#, python-brace-format
msgid ""
"Fixed AK {ak_name} assigned by solver to room {solver_room} is fixed to room "
"{slot_room}"
msgstr ""
"Dem fix geplanten AK {ak_name} wurde vom Solver Raum {solver_room} zugewiesen, "
"dabei ist der AK bereits fix in Raum {slot_room} eingeplant."
#: AKModel/models.py:465
#, python-brace-format
msgid ""
"Fixed AK {ak_name} assigned by solver to start at {solver_start} is fixed to "
"start at {slot_start}"
msgstr ""
"Dem fix geplanten AK {ak_name} wurde vom Solver die Startzeit {solver_start} zugewiesen, "
"dabei ist der AK bereits für {slot_start} eingeplant."
#: AKModel/models.py:180
msgid "Nickname"
msgstr "Spitzname"
#: AKModel/models.py:169
#: AKModel/models.py:182
msgid "Name to identify an AK owner by"
msgstr "Name, durch den eine AK-Leitung identifiziert wird"
#: AKModel/models.py:170
#: AKModel/models.py:183
msgid "Slug"
msgstr "Slug"
#: AKModel/models.py:170
#: AKModel/models.py:183
msgid "Slug for URL generation"
msgstr "Slug für URL-Generierung"
#: AKModel/models.py:171
#: AKModel/models.py:184
msgid "Institution"
msgstr "Instutution"
#: AKModel/models.py:171
#: AKModel/models.py:184
msgid "Uni etc."
msgstr "Universität o.ä."
#: AKModel/models.py:172 AKModel/models.py:340
#: AKModel/models.py:185 AKModel/models.py:355
msgid "Web Link"
msgstr "Internet Link"
#: AKModel/models.py:172
#: AKModel/models.py:185
msgid "Link to Homepage"
msgstr "Link zu Homepage oder Webseite"
#: AKModel/models.py:178 AKModel/models.py:712
#: AKModel/models.py:191 AKModel/models.py:741
msgid "AK Owner"
msgstr "AK-Leitung"
#: AKModel/models.py:179
#: AKModel/models.py:192
msgid "AK Owners"
msgstr "AK-Leitungen"
#: AKModel/models.py:243
#: AKModel/models.py:256
msgid "Name of the AK Category"
msgstr "Name der AK-Kategorie"
#: AKModel/models.py:244 AKModel/models.py:268
#: AKModel/models.py:257 AKModel/models.py:281
msgid "Color"
msgstr "Farbe"
#: AKModel/models.py:244 AKModel/models.py:268
#: AKModel/models.py:257 AKModel/models.py:281
msgid "Color for displaying"
msgstr "Farbe für die Anzeige"
#: AKModel/models.py:245 AKModel/models.py:334
#: AKModel/models.py:258 AKModel/models.py:349
msgid "Description"
msgstr "Beschreibung"
#: AKModel/models.py:246
#: AKModel/models.py:259
msgid "Short description of this AK Category"
msgstr "Beschreibung der AK-Kategorie"
#: AKModel/models.py:247
#: AKModel/models.py:260
msgid "Present by default"
msgstr "Defaultmäßig präsentieren"
#: AKModel/models.py:248
#: AKModel/models.py:261
msgid ""
"Present AKs of this category by default if AK owner did not specify whether "
"this AK should be presented?"
......@@ -522,152 +582,152 @@ msgstr ""
"AKs dieser Kategorie standardmäßig vorstellen, wenn die Leitungen das für "
"ihren AK nicht explizit spezifiziert haben?"
#: AKModel/models.py:256
#: AKModel/models.py:269
msgid "AK Categories"
msgstr "AK-Kategorien"
#: AKModel/models.py:267
#: AKModel/models.py:280
msgid "Name of the AK Track"
msgstr "Name des AK-Tracks"
#: AKModel/models.py:274
#: AKModel/models.py:287
msgid "AK Track"
msgstr "AK-Track"
#: AKModel/models.py:275
#: AKModel/models.py:288
msgid "AK Tracks"
msgstr "AK-Tracks"
#: AKModel/models.py:294
#: AKModel/models.py:307
msgid "Name of the Requirement"
msgstr "Name der Anforderung"
#: AKModel/models.py:300 AKModel/models.py:716
#: AKModel/models.py:313 AKModel/models.py:745
msgid "AK Requirement"
msgstr "AK-Anforderung"
#: AKModel/models.py:301
#: AKModel/models.py:314
msgid "AK Requirements"
msgstr "AK-Anforderungen"
#: AKModel/models.py:313
#: AKModel/models.py:326
msgid "Name describing the type"
msgstr "Name, der den Typ beschreibt"
#: AKModel/models.py:319
#: AKModel/models.py:332
msgid "AK Type"
msgstr "AK Typ"
#: AKModel/models.py:320
#: AKModel/models.py:333
msgid "AK Types"
msgstr "AK-Typen"
#: AKModel/models.py:331
#: AKModel/models.py:344
msgid "Name of the AK"
msgstr "Name des AKs"
#: AKModel/models.py:332
#: AKModel/models.py:346
msgid "Short Name"
msgstr "Kurzer Name"
#: AKModel/models.py:333
#: AKModel/models.py:348
msgid "Name displayed in the schedule"
msgstr "Name zur Anzeige im AK-Plan"
#: AKModel/models.py:334
#: AKModel/models.py:349
msgid "Description of the AK"
msgstr "Beschreibung des AKs"
#: AKModel/models.py:336
#: AKModel/models.py:351
msgid "Owners"
msgstr "Leitungen"
#: AKModel/models.py:337
#: AKModel/models.py:352
msgid "Those organizing the AK"
msgstr "Menschen, die den AK organisieren und halten"
#: AKModel/models.py:340
#: AKModel/models.py:355
msgid "Link to wiki page"
msgstr "Link zur Wiki Seite"
#: AKModel/models.py:341
#: AKModel/models.py:356
msgid "Protocol Link"
msgstr "Protokolllink"
#: AKModel/models.py:341
#: AKModel/models.py:356
msgid "Link to protocol"
msgstr "Link zum Protokoll"
#: AKModel/models.py:343
#: AKModel/models.py:358
msgid "Category"
msgstr "Kategorie"
#: AKModel/models.py:344
#: AKModel/models.py:359
msgid "Category of the AK"
msgstr "Kategorie des AKs"
#: AKModel/models.py:345
#: AKModel/models.py:360
msgid "Types"
msgstr "Typen"
#: AKModel/models.py:346
#: AKModel/models.py:361
msgid "This AK is"
msgstr "Dieser AK ist"
#: AKModel/models.py:347
#: AKModel/models.py:362
msgid "Track"
msgstr "Track"
#: AKModel/models.py:348
#: AKModel/models.py:363
msgid "Track the AK belongs to"
msgstr "Track zu dem der AK gehört"
#: AKModel/models.py:350
#: AKModel/models.py:365
msgid "Resolution Intention"
msgstr "Resolutionsabsicht"
#: AKModel/models.py:351
#: AKModel/models.py:366
msgid "Intends to submit a resolution"
msgstr "Beabsichtigt eine Resolution einzureichen"
#: AKModel/models.py:352
#: AKModel/models.py:367
msgid "Present this AK"
msgstr "AK präsentieren"
#: AKModel/models.py:353
#: AKModel/models.py:368
msgid "Present results of this AK"
msgstr "Die Ergebnisse dieses AKs vorstellen"
#: AKModel/models.py:355 AKModel/views/status.py:167
#: AKModel/models.py:370 AKModel/views/status.py:167
msgid "Requirements"
msgstr "Anforderungen"
#: AKModel/models.py:356
#: AKModel/models.py:371
msgid "AK's Requirements"
msgstr "Anforderungen des AKs"
#: AKModel/models.py:358
#: AKModel/models.py:373
msgid "Conflicting AKs"
msgstr "AK-Konflikte"
#: AKModel/models.py:359
#: AKModel/models.py:374
msgid "AKs that conflict and thus must not take place at the same time"
msgstr ""
"AKs, die Konflikte haben und deshalb nicht gleichzeitig stattfinden dürfen"
#: AKModel/models.py:360
#: AKModel/models.py:375
msgid "Prerequisite AKs"
msgstr "Vorausgesetzte AKs"
#: AKModel/models.py:361
#: AKModel/models.py:376
msgid "AKs that should precede this AK in the schedule"
msgstr "AKs die im AK-Plan vor diesem AK stattfinden müssen"
#: AKModel/models.py:363
#: AKModel/models.py:378
msgid "Organizational Notes"
msgstr "Notizen zur Organisation"
#: AKModel/models.py:364
#: AKModel/models.py:379
msgid ""
"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/"
......@@ -677,295 +737,370 @@ msgstr ""
"Anmerkungen bitte den Button für Direktnachrichten verwenden (nach dem "
"Anlegen/Bearbeiten)."
#: AKModel/models.py:367
#: AKModel/models.py:382
msgid "Interest"
msgstr "Interesse"
#: AKModel/models.py:367
#: AKModel/models.py:382
msgid "Expected number of people"
msgstr "Erwartete Personenzahl"
#: AKModel/models.py:368
#: AKModel/models.py:383
msgid "Interest Counter"
msgstr "Interessenszähler"
#: AKModel/models.py:369
#: AKModel/models.py:384
msgid "People who have indicated interest online"
msgstr "Anzahl Personen, die online Interesse bekundet haben"
#: AKModel/models.py:374
#: AKModel/models.py:389
msgid "Export?"
msgstr "Export?"
#: AKModel/models.py:375
#: AKModel/models.py:390
msgid "Include AK in wiki export?"
msgstr "AK bei Wiki-Export berücksichtigen?"
#: AKModel/models.py:507
#: AKModel/models.py:536
msgid "Name or number of the room"
msgstr "Name oder Nummer des Raums"
#: AKModel/models.py:508
#: AKModel/models.py:537
msgid "Location"
msgstr "Ort"
#: AKModel/models.py:509
#: AKModel/models.py:538
msgid "Name or number of the location"
msgstr "Name oder Nummer des Ortes"
#: AKModel/models.py:510
#: AKModel/models.py:539
msgid "Capacity"
msgstr "Kapazität"
#: AKModel/models.py:511
#: AKModel/models.py:540
msgid "Maximum number of people (-1 for unlimited)."
msgstr "Maximale Personenzahl (-1 wenn unbeschränkt)."
#: AKModel/models.py:512
#: AKModel/models.py:541
msgid "Properties"
msgstr "Eigenschaften"
#: AKModel/models.py:513
#: AKModel/models.py:542
msgid "AK requirements fulfilled by the room"
msgstr "AK-Anforderungen, die dieser Raum erfüllt"
#: AKModel/models.py:522 AKModel/views/status.py:59
#: AKModel/models.py:551 AKModel/views/status.py:59
msgid "Rooms"
msgstr "Räume"
#: AKModel/models.py:545
#: AKModel/models.py:574
msgid "AK being mapped"
msgstr "AK, der zugeordnet wird"
#: AKModel/models.py:547
#: AKModel/models.py:576
msgid "Room the AK will take place in"
msgstr "Raum in dem der AK stattfindet"
#: AKModel/models.py:548 AKModel/models.py:891
#: AKModel/models.py:577 AKModel/models.py:920
msgid "Slot Begin"
msgstr "Beginn des Slots"
#: AKModel/models.py:548 AKModel/models.py:891
#: AKModel/models.py:577 AKModel/models.py:920
msgid "Time and date the slot begins"
msgstr "Zeit und Datum zu der der AK beginnt"
#: AKModel/models.py:550
#: AKModel/models.py:579
msgid "Duration"
msgstr "Dauer"
#: AKModel/models.py:551
#: AKModel/models.py:580
msgid "Length in hours"
msgstr "Länge in Stunden"
#: AKModel/models.py:553
#: AKModel/models.py:582
msgid "Scheduling fixed"
msgstr "Planung fix"
#: AKModel/models.py:554
#: AKModel/models.py:583
msgid "Length and time of this AK should not be changed"
msgstr "Dauer und Zeit dieses AKs sollten nicht verändert werden"
#: AKModel/models.py:559
#: AKModel/models.py:588
msgid "Last update"
msgstr "Letzte Aktualisierung"
#: AKModel/models.py:562
#: AKModel/models.py:591
msgid "AK Slot"
msgstr "AK-Slot"
#: AKModel/models.py:563 AKModel/models.py:709
#: AKModel/models.py:592 AKModel/models.py:738
msgid "AK Slots"
msgstr "AK-Slot"
#: AKModel/models.py:585 AKModel/models.py:594
#: AKModel/models.py:614 AKModel/models.py:623
msgid "Not scheduled yet"
msgstr "Noch nicht geplant"
#: AKModel/models.py:642
#: AKModel/models.py:671
msgid "AK this message belongs to"
msgstr "AK zu dem die Nachricht gehört"
#: AKModel/models.py:643
#: AKModel/models.py:672
msgid "Message text"
msgstr "Nachrichtentext"
#: AKModel/models.py:644
#: AKModel/models.py:673
msgid "Message to the organizers. This is not publicly visible."
msgstr ""
"Nachricht an die Organisator*innen. Diese ist nicht öffentlich sichtbar."
#: AKModel/models.py:648
#: AKModel/models.py:677
msgid "Resolved"
msgstr "Erledigt"
#: AKModel/models.py:649
#: AKModel/models.py:678
msgid "This message has been resolved (no further action needed)"
msgstr ""
"Diese Nachricht wurde vollständig bearbeitet (keine weiteren Aktionen "
"notwendig)"
#: AKModel/models.py:652
#: AKModel/models.py:681
msgid "AK Orga Message"
msgstr "AK-Organachricht"
#: AKModel/models.py:653
#: AKModel/models.py:682
msgid "AK Orga Messages"
msgstr "AK-Organachrichten"
#: AKModel/models.py:670
#: AKModel/models.py:699
msgid "Constraint Violation"
msgstr "Constraintverletzung"
#: AKModel/models.py:671
#: AKModel/models.py:700
msgid "Constraint Violations"
msgstr "Constraintverletzungen"
#: AKModel/models.py:678
#: AKModel/models.py:707
msgid "Owner has two parallel slots"
msgstr "Leitung hat zwei Slots parallel"
#: AKModel/models.py:679
#: AKModel/models.py:708
msgid "AK Slot was scheduled outside the AK's availabilities"
msgstr "AK Slot wurde außerhalb der Verfügbarkeit des AKs platziert"
#: AKModel/models.py:680
#: AKModel/models.py:709
msgid "Room has two AK slots scheduled at the same time"
msgstr "Raum hat zwei AK Slots gleichzeitig"
#: AKModel/models.py:681
#: AKModel/models.py:710
msgid "Room does not satisfy the requirement of the scheduled AK"
msgstr "Room erfüllt die Anforderungen des platzierten AKs nicht"
#: AKModel/models.py:682
#: AKModel/models.py:711
msgid "AK Slot is scheduled at the same time as an AK listed as a conflict"
msgstr ""
"AK Slot wurde wurde zur gleichen Zeit wie ein Konflikt des AKs platziert"
#: AKModel/models.py:683
#: AKModel/models.py:712
msgid "AK Slot is scheduled before an AK listed as a prerequisite"
msgstr "AK Slot wurde vor einem als Voraussetzung gelisteten AK platziert"
#: AKModel/models.py:685
#: AKModel/models.py:714
msgid ""
"AK Slot for AK with intention to submit a resolution is scheduled after "
"resolution deadline"
msgstr ""
"AK Slot eines AKs mit Resoabsicht wurde nach der Resodeadline platziert"
#: AKModel/models.py:686
#: AKModel/models.py:715
msgid "AK Slot in a category is outside that categories availabilities"
msgstr "AK Slot wurde außerhalb der Verfügbarkeiten seiner Kategorie"
#: AKModel/models.py:687
#: AKModel/models.py:716
msgid "Two AK Slots for the same AK scheduled at the same time"
msgstr "Zwei AK Slots eines AKs wurden zur selben Zeit platziert"
#: AKModel/models.py:688
#: AKModel/models.py:717
msgid "Room does not have enough space for interest in scheduled AK Slot"
msgstr "Room hat nicht genug Platz für das Interesse am geplanten AK-Slot"
#: AKModel/models.py:689
#: AKModel/models.py:718
msgid "AK Slot is scheduled outside the event's availabilities"
msgstr "AK Slot wurde außerhalb der Verfügbarkeit des Events platziert"
#: AKModel/models.py:695
#: AKModel/models.py:724
msgid "Warning"
msgstr "Warnung"
#: AKModel/models.py:696
#: AKModel/models.py:725
msgid "Violation"
msgstr "Verletzung"
#: AKModel/models.py:698
#: AKModel/models.py:727
msgid "Type"
msgstr "Art"
#: AKModel/models.py:699
#: AKModel/models.py:728
msgid "Type of violation, i.e. what kind of constraint was violated"
msgstr "Art der Verletzung, gibt an welche Art Constraint verletzt wurde"
#: AKModel/models.py:700
#: AKModel/models.py:729
msgid "Level"
msgstr "Level"
#: AKModel/models.py:701
#: AKModel/models.py:730
msgid "Severity level of the violation"
msgstr "Schweregrad der Verletzung"
#: AKModel/models.py:708
#: AKModel/models.py:737
msgid "AK(s) belonging to this constraint"
msgstr "AK(s), die zu diesem Constraint gehören"
#: AKModel/models.py:710
#: AKModel/models.py:739
msgid "AK Slot(s) belonging to this constraint"
msgstr "AK Slot(s), die zu diesem Constraint gehören"
#: AKModel/models.py:712
#: AKModel/models.py:741
msgid "AK Owner belonging to this constraint"
msgstr "AK Leitung(en), die zu diesem Constraint gehören"
#: AKModel/models.py:714
#: AKModel/models.py:743
msgid "Room belonging to this constraint"
msgstr "Raum, der zu diesem Constraint gehört"
#: AKModel/models.py:717
#: AKModel/models.py:746
msgid "AK Requirement belonging to this constraint"
msgstr "AK Anforderung, die zu diesem Constraint gehört"
#: AKModel/models.py:719
#: AKModel/models.py:748
msgid "AK Category belonging to this constraint"
msgstr "AK Kategorie, di zu diesem Constraint gehört"
#: AKModel/models.py:721
#: AKModel/models.py:750
msgid "Comment"
msgstr "Kommentar"
#: AKModel/models.py:721
#: AKModel/models.py:750
msgid "Comment or further details for this violation"
msgstr "Kommentar oder weitere Details zu dieser Vereletzung"
#: AKModel/models.py:724
#: AKModel/models.py:753
msgid "Timestamp"
msgstr "Timestamp"
#: AKModel/models.py:724
#: AKModel/models.py:753
msgid "Time of creation"
msgstr "Zeitpunkt der ERstellung"
#: AKModel/models.py:725
#: AKModel/models.py:754
msgid "Manually Resolved"
msgstr "Manuell behoben"
#: AKModel/models.py:726
#: AKModel/models.py:755
msgid "Mark this violation manually as resolved"
msgstr "Markiere diese Verletzung manuell als behoben"
#: AKModel/models.py:753 AKModel/templates/admin/AKModel/aks_by_user.html:22
#: AKModel/models.py:782 AKModel/templates/admin/AKModel/aks_by_user.html:22
#: AKModel/templates/admin/AKModel/requirements_overview.html:27
msgid "Details"
msgstr "Details"
#: AKModel/models.py:887
#: AKModel/models.py:916
msgid "Default Slot"
msgstr "Standardslot"
#: AKModel/models.py:892
#: AKModel/models.py:921
msgid "Slot End"
msgstr "Ende des Slots"
#: AKModel/models.py:892
#: AKModel/models.py:921
msgid "Time and date the slot ends"
msgstr "Zeit und Datum zu der der Slot endet"
#: AKModel/models.py:897
#: AKModel/models.py:926
msgid "Primary categories"
msgstr "Primäre Kategorien"
#: AKModel/models.py:898
#: AKModel/models.py:927
msgid "Categories that should be assigned to this slot primarily"
msgstr "Kategorieren, die diesem Slot primär zugewiesen werden sollen"
#: AKModel/site.py:14
#: AKModel/models.py:936
msgid "Conflicts"
msgstr "Konflikte"
#: AKModel/models.py:939
msgid "Prerequisites"
msgstr "Voraussetzungen"
#: AKModel/availability/models.py:89 AKModel/models.py:1358
#: AKModel/models.py:1435
msgid "Participant"
msgstr "Teilnehmer*in"
#: AKModel/availability/models.py:90
msgid "Participant whose availability this is"
msgstr "Teilnehmer*in, deren Verfügbarkeit hier abgebildet wird"
#: AKModel/models.py:1359
msgid "Participants"
msgstr "Teilnehmende"
#: AKModel/models.py:1363
msgid ""
"Name to identify a participant by (in case of questions from the organizers)"
msgstr "Name, zur Identifikation bei Rückfragen von den Organisator*innen"
#: AKModel/models.py:1370
msgid "Participant's Requirements"
msgstr "Anforderungen der Teilnehmer*in"
#: AKModel/models.py:1370
#, python-brace-format
msgid "Anonymous {pk}"
msgstr "Anonym {pk}"
#: AKModel/models.py:1428
msgid "AK Preference"
msgstr "AK Präferenz"
#: AKModel/models.py:1429
msgid "AK Preferences"
msgstr "AK Präferenzen"
#: AKModel/models.py:1436
msgid "Participant this preference belongs to"
msgstr "Teilnehmer*in, zu der die Präferenz gehört"
#: AKModel/models.py:1439
msgid "AK Slot this preference belongs to"
msgstr "AK-Slot zu dem die Präferenz gehört"
#: AKModel/models.py:1445
msgid "Ignore"
msgstr "Ignorieren"
#: AKModel/models.py:1446
msgid "Prefer"
msgstr "Präferenz"
#: AKModel/models.py:1447
msgid "Strong prefer"
msgstr "Große Präferenz"
#: AKModel/models.py:1448
msgid "Required"
msgstr "Erforderlich"
#: AKModel/models.py:1450
msgid "Preference"
msgstr "Präferenz"
#: AKModel/models.py:1451
msgid "Preference level for the AK"
msgstr "Präferenz-Level für den AK"
#: AKModel/site.py:13 AKModel/site.py:14
msgid "Administration"
msgstr "Verwaltung"
......@@ -1176,7 +1311,7 @@ msgstr "Anforderungen für das Event"
msgid "AK CSV Export"
msgstr "AK-CSV-Export"
#: AKModel/views/ak.py:48
#: AKModel/views/ak.py:133
msgid "AK Wiki Export"
msgstr "AK-Wiki-Export"
......@@ -1361,6 +1496,14 @@ msgstr "AKs als CSV exportieren"
msgid "Export AKs for Wiki"
msgstr "AKs im Wiki-Format exportieren"
#: AKModel/views/status.py:158
msgid "Export AKs as JSON"
msgstr "AKs als JSON exportieren"
#: AKModel/views/status.py:162
msgid "Import AK schedule from JSON"
msgstr "AK-Plan aus JSON importieren"
#: AKModel/views/status.py:179
msgid "Show AKs for requirements"
msgstr "Zu Anforderungen gehörige AKs anzeigen"
......@@ -1369,6 +1512,10 @@ msgstr "Zu Anforderungen gehörige AKs anzeigen"
msgid "Event Status"
msgstr "Eventstatus"
#, python-format
#~ msgid "Invalid JSON format: field '%(field)s' is missing"
#~ msgstr "Ungültige JSON-Eingabe: das Feld '%(field)s' fehlt"
#~ msgid "Opening time for expression of interest."
#~ msgstr "Öffnungszeitpunkt für die Angabe von Interesse an AKs."
......
# Generated by Django 4.2.13 on 2025-03-03 19:59
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('AKModel', '0062_interest_no_history'),
]
operations = [
migrations.AlterField(
model_name='ak',
name='name',
field=models.CharField(help_text='Name of the AK', max_length=256, validators=[django.core.validators.RegexValidator(inverse_match=True, message='May not contain quotation marks', regex='[\'\\"´`]+'), django.core.validators.RegexValidator(message='Must contain at least one letter or digit', regex='[\\w\\s]+')], verbose_name='Name'),
),
migrations.AlterField(
model_name='ak',
name='short_name',
field=models.CharField(blank=True, help_text='Name displayed in the schedule', max_length=64, validators=[django.core.validators.RegexValidator(inverse_match=True, message='May not contain quotation marks', regex='[\'\\"´`]+')], verbose_name='Short Name'),
),
migrations.AlterField(
model_name='akowner',
name='name',
field=models.CharField(help_text='Name to identify an AK owner by', max_length=64, validators=[django.core.validators.RegexValidator(inverse_match=True, message='May not contain quotation marks', regex='[\'\\"´`]+'), django.core.validators.RegexValidator(message='Must contain at least one letter or digit', regex='[\\w\\s]+')], verbose_name='Nickname'),
),
migrations.AlterField(
model_name='historicalak',
name='name',
field=models.CharField(help_text='Name of the AK', max_length=256, validators=[django.core.validators.RegexValidator(inverse_match=True, message='May not contain quotation marks', regex='[\'\\"´`]+'), django.core.validators.RegexValidator(message='Must contain at least one letter or digit', regex='[\\w\\s]+')], verbose_name='Name'),
),
migrations.AlterField(
model_name='historicalak',
name='short_name',
field=models.CharField(blank=True, help_text='Name displayed in the schedule', max_length=64, validators=[django.core.validators.RegexValidator(inverse_match=True, message='May not contain quotation marks', regex='[\'\\"´`]+')], verbose_name='Short Name'),
),
]
# Generated by Django 5.1.6 on 2025-03-29 22:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("AKModel", "0063_field_validators"),
]
operations = [
migrations.AddField(
model_name="event",
name="export_slot",
field=models.DecimalField(
decimal_places=2,
default=1,
help_text="Slot duration in hours that is used in the timeslot discretization, when this event is exported for the solver.",
max_digits=4,
verbose_name="Export Slot Length",
),
),
]
# Generated by Django 4.2.13 on 2025-02-10 10:23
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("AKModel", "0064_event_export_slot"),
]
operations = [
migrations.CreateModel(
name="EventParticipant",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"name",
models.CharField(
blank=True,
help_text="Name to identify a participant by (in case of questions from the organizers)",
max_length=64,
verbose_name="Nickname",
),
),
(
"institution",
models.CharField(
blank=True,
help_text="Uni etc.",
max_length=128,
verbose_name="Institution",
),
),
(
"event",
models.ForeignKey(
help_text="Associated event",
on_delete=django.db.models.deletion.CASCADE,
to="AKModel.event",
verbose_name="Event",
),
),
],
options={
"verbose_name": "Participant",
"verbose_name_plural": "Participants",
"ordering": ["name"],
},
),
migrations.CreateModel(
name="AKPreference",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"preference",
models.PositiveSmallIntegerField(
choices=[
(0, "Ignore"),
(1, "Prefer"),
(2, "Strong prefer"),
(3, "Required"),
],
default=0,
help_text="Preference level for the AK",
verbose_name="Preference",
),
),
(
"ak",
models.ForeignKey(
help_text="AK this preference belongs to",
on_delete=django.db.models.deletion.CASCADE,
to="AKModel.ak",
verbose_name="AK",
),
),
(
"event",
models.ForeignKey(
help_text="Associated event",
on_delete=django.db.models.deletion.CASCADE,
to="AKModel.event",
verbose_name="Event",
),
),
(
"participant",
models.ForeignKey(
help_text="Participant this preference belongs to",
on_delete=django.db.models.deletion.CASCADE,
to="AKModel.eventparticipant",
verbose_name="Participant",
),
),
],
options={
"verbose_name": "AK Preference",
"verbose_name_plural": "AK Preferences",
},
),
migrations.AddField(
model_name="availability",
name="participant",
field=models.ForeignKey(
blank=True,
help_text="Participant whose availability this is",
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="availabilities",
to="AKModel.eventparticipant",
verbose_name="Participant",
),
),
]
# Generated by Django 4.2.13 on 2025-02-10 22:31
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("AKModel", "0065_eventparticipant_akpreference_and_more"),
]
operations = [
migrations.AddField(
model_name="akpreference",
name="slot",
field=models.ForeignKey(
default=None,
help_text="AKSlot this preference belongs to",
on_delete=django.db.models.deletion.CASCADE,
to="AKModel.akslot",
verbose_name="AKSlot",
),
preserve_default=False,
),
migrations.AlterUniqueTogether(
name="akpreference",
unique_together={("event", "participant", "slot")},
),
migrations.RemoveField(
model_name="akpreference",
name="ak",
),
]
# Generated by Django 4.2.13 on 2025-02-11 00:23
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
(
"AKModel",
"0066_akpreference_slot_alter_akpreference_unique_together_and_more",
),
]
operations = [
migrations.AddField(
model_name="eventparticipant",
name="requirements",
field=models.ManyToManyField(
blank=True,
help_text="Participant's Requirements",
to="AKModel.akrequirement",
verbose_name="Requirements",
),
),
migrations.AlterField(
model_name="akpreference",
name="slot",
field=models.ForeignKey(
help_text="AK Slot this preference belongs to",
on_delete=django.db.models.deletion.CASCADE,
to="AKModel.akslot",
verbose_name="AK Slot",
),
),
]
import itertools
from datetime import timedelta
import json
import math
from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import Any, Generator, Iterable
from django.db import models
from django.apps import apps
from django.conf import settings
from django.core.validators import RegexValidator
from django.db import models, transaction
from django.db.models import Count
from django.urls import reverse_lazy
from django.utils import timezone
from django.utils.datetime_safe import datetime
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from simple_history.models import HistoricalRecords
from timezone_field import TimeZoneField
# Custom validators to be used for some of the fields
# Prevent inclusion of the quotation marks ' " ´ `
# This may be necessary to prevent javascript issues
no_quotation_marks_validator = RegexValidator(regex=r"['\"´`]+", inverse_match=True,
message=_('May not contain quotation marks'))
# Enforce that the field contains of at least one letter or digit (and not just special characters
# This prevents issues when autogenerating slugs from that field
slugable_validator = RegexValidator(regex=r"[\w\s]+", message=_('Must contain at least one letter or digit'))
@dataclass
class OptimizerTimeslot:
"""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."""
def merge(self, other: "OptimizerTimeslot") -> "OptimizerTimeslot":
"""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.
"""
avail = self.avail.merge_with(other.avail)
constraints = self.constraints.union(other.constraints)
return OptimizerTimeslot(
avail=avail, idx=self.idx, constraints=constraints
)
def __repr__(self) -> str:
return f"({self.avail.simplified}, {self.idx}, {self.constraints})"
TimeslotBlock = list[OptimizerTimeslot]
def merge_blocks(
blocks: Iterable[TimeslotBlock]
) -> Iterable[TimeslotBlock]:
"""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.
:param blocks: iterable of blocks to merge.
:return: iterable of merged blocks.
:rtype: iterable over lists of OptimizerTimeslot objects
"""
if not blocks:
return []
# flatten timeslot iterables to single chain
timeslot_chain = itertools.chain.from_iterable(blocks)
# sort timeslots according to start
timeslots = sorted(
timeslot_chain,
key=lambda slot: slot.avail.start
)
if not timeslots:
return []
all_blocks = []
current_block = [timeslots[0]]
timeslots = timeslots[1:]
for slot in timeslots:
if current_block and slot.avail.overlaps(current_block[-1].avail, strict=True):
if (
slot.avail.start == current_block[-1].avail.start
and slot.avail.end == current_block[-1].avail.end
):
# the same timeslot -> merge
current_block[-1] = current_block[-1].merge(slot)
else:
# partial overlap of interiors -> not supported
raise ValueError(
"Partially overlapping timeslots are not supported!"
f" ({current_block[-1].avail.simplified}, {slot.avail.simplified})"
)
elif not current_block or slot.avail.overlaps(current_block[-1].avail, strict=False):
# only endpoints in intersection -> same block
current_block.append(slot)
else:
# no overlap at all -> new block
all_blocks.append(current_block)
current_block = [slot]
if current_block:
all_blocks.append(current_block)
return all_blocks
class Event(models.Model):
"""
......@@ -32,8 +141,9 @@ class Event(models.Model):
help_text=_('When should AKs with intention to submit a resolution be done?'))
interest_start = models.DateTimeField(verbose_name=_('Interest Window Start'), blank=True, null=True,
help_text=
_('Opening time for expression of interest. When left blank, no interest indication will be possible.'))
help_text=
_('Opening time for expression of interest. When left blank, no interest '
'indication will be possible.'))
interest_end = models.DateTimeField(verbose_name=_('Interest Window End'), blank=True, null=True,
help_text=_('Closing time for expression of interest.'))
......@@ -45,16 +155,22 @@ class Event(models.Model):
plan_hidden = models.BooleanField(verbose_name=_('Plan Hidden'), help_text=_('Hides plan for non-staff users'),
default=True)
plan_published_at = models.DateTimeField(verbose_name=_('Plan published at'), blank=True, null=True,
help_text=_('Timestamp at which the plan was published'))
help_text=_('Timestamp at which the plan was published'))
base_url = models.URLField(verbose_name=_("Base URL"), help_text=_("Prefix for wiki link construction"), blank=True)
wiki_export_template_name = models.CharField(verbose_name=_("Wiki Export Template Name"), blank=True, max_length=50)
default_slot = models.DecimalField(max_digits=4, decimal_places=2, default=2, verbose_name=_('Default Slot Length'),
help_text=_('Default length in hours that is assumed for AKs in this event.'))
export_slot = models.DecimalField(max_digits=4, decimal_places=2, default=1, verbose_name=_('Export Slot Length'),
help_text=_(
'Slot duration in hours that is used in the timeslot discretization, '
'when this event is exported for the solver.'
))
contact_email = models.EmailField(verbose_name=_("Contact email address"), blank=True,
help_text=_("An email address that is displayed on every page "
"and can be used for all kinds of questions"))
help_text=_("An email address that is displayed on every page "
"and can be used for all kinds of questions"))
class Meta:
verbose_name = _('Event')
......@@ -85,7 +201,7 @@ class Event(models.Model):
event = Event.objects.filter(active=True).order_by('start').first()
# No active event? Return the next event taking place
if event is None:
event = Event.objects.order_by('start').filter(start__gt=datetime.now()).first()
event = Event.objects.order_by('start').filter(start__gt=datetime.now().astimezone()).first()
return event
def get_categories_with_aks(self, wishes_seperately=False,
......@@ -162,11 +278,266 @@ class Event(models.Model):
.filter(availabilities__count=0, owners__count__gt=0)
)
def _generate_slots_from_block(
self,
start: datetime,
end: datetime,
slot_duration: timedelta,
*,
slot_index: int = 0,
constraints: set[str] | None = None,
) -> Generator[TimeslotBlock, None, int]:
"""Discretize a time range into timeslots.
Uses a uniform discretization into discrete slots of length `slot_duration`,
starting at `start`. No incomplete timeslots are generated, i.e.
if (`end` - `start`) is not a whole number multiple of `slot_duration`
then the last incomplete timeslot is dropped.
:param start: Start of the time range.
:param end: Start of the time range.
:param slot_duration: Duration of a single timeslot in the discretization.
:param slot_index: index of the first timeslot. Defaults to 0.
:yield: Block of optimizer timeslots as the discretization result.
:ytype: list of OptimizerTimeslot
:return: The first slot index after the yielded blocks, i.e.
`slot_index` + total # generated timeslots
:rtype: int
"""
# local import to prevent cyclic import
# pylint: disable=import-outside-toplevel
from AKModel.availability.models import Availability
current_slot_start = start
previous_slot_start: datetime | None = None
if constraints is None:
constraints = set()
current_block = []
room_availabilities = list({
availability
for room in Room.objects.filter(event=self)
for availability in room.availabilities.all()
})
while current_slot_start + slot_duration <= end:
slot = Availability(
event=self,
start=current_slot_start,
end=current_slot_start + slot_duration,
)
if any((availability.contains(slot) for availability in room_availabilities)):
# no gap in a block
if (
previous_slot_start is not None
and previous_slot_start + slot_duration < current_slot_start
):
yield current_block
current_block = []
current_block.append(
OptimizerTimeslot(avail=slot, idx=slot_index, constraints=constraints)
)
previous_slot_start = current_slot_start
slot_index += 1
current_slot_start += slot_duration
if current_block:
yield current_block
return slot_index
def uniform_time_slots(self, *, slots_in_an_hour: float) -> Iterable[TimeslotBlock]:
"""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.
:param 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
"""
all_category_constraints = AKCategory.create_category_optimizer_constraints(
AKCategory.objects.filter(event=self).all()
)
yield from self._generate_slots_from_block(
start=self.start,
end=self.end,
slot_duration=timedelta(hours=1.0 / slots_in_an_hour),
constraints=all_category_constraints,
)
def default_time_slots(self, *, slots_in_an_hour: float) -> Iterable[TimeslotBlock]:
"""Discretize all default slots into blocks of timeslots.
In the discretization each default slot corresponds to one block.
:param 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
"""
slot_duration = timedelta(hours=1.0 / slots_in_an_hour)
slot_index = 0
for block_slot in DefaultSlot.objects.filter(event=self).order_by("start", "end"):
category_constraints = AKCategory.create_category_optimizer_constraints(
block_slot.primary_categories.all()
)
slot_index = yield from self._generate_slots_from_block(
start=block_slot.start,
end=block_slot.end,
slot_duration=slot_duration,
slot_index=slot_index,
constraints=category_constraints,
)
def discretize_timeslots(self, *, slots_in_an_hour: float | None = None) -> Iterable[TimeslotBlock]:
""""Choose discretization scheme.
Uses default_time_slots if the event has any DefaultSlot, otherwise uniform_time_slots.
:param 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
"""
if slots_in_an_hour is None:
slots_in_an_hour = 1.0 / float(self.export_slot)
if DefaultSlot.objects.filter(event=self).exists():
# discretize default slots if they exists
yield from merge_blocks(self.default_time_slots(slots_in_an_hour=slots_in_an_hour))
else:
yield from self.uniform_time_slots(slots_in_an_hour=slots_in_an_hour)
@transaction.atomic
def schedule_from_json(
self, schedule: str | dict[str, Any], *, check_for_data_inconsistency: bool = True
) -> int:
"""Load AK schedule from a json string.
:param 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
"""
if isinstance(schedule, str):
schedule = json.loads(schedule)
if "input" not in schedule or "scheduled_aks" not in schedule:
raise ValueError(_("Cannot parse malformed JSON input."))
if apps.is_installed("AKSolverInterface") and check_for_data_inconsistency:
from AKSolverInterface.serializers import ExportEventSerializer # pylint: disable=import-outside-toplevel
export_dict = ExportEventSerializer(self).data
if schedule["input"] != export_dict:
raise ValueError(_("Data has changed since the export. Reexport and run the solver again."))
slots_in_an_hour = schedule["input"]["timeslots"]["info"]["duration"]
timeslot_dict = {
timeslot.idx: timeslot
for block in self.discretize_timeslots(slots_in_an_hour=slots_in_an_hour)
for timeslot in block
}
slots_updated = 0
for scheduled_slot in schedule["scheduled_aks"]:
scheduled_slot["timeslot_ids"] = list(map(int, scheduled_slot["timeslot_ids"]))
slot = AKSlot.objects.get(id=int(scheduled_slot["ak_id"]))
if not scheduled_slot["timeslot_ids"]:
raise ValueError(
_("AK {ak_name} is not assigned any timeslot by the solver").format(ak_name=slot.ak.name)
)
start_timeslot = timeslot_dict[min(scheduled_slot["timeslot_ids"])].avail
end_timeslot = timeslot_dict[max(scheduled_slot["timeslot_ids"])].avail
solver_duration = (end_timeslot.end - start_timeslot.start).total_seconds() / 3600.0
if solver_duration + 2e-4 < slot.duration:
raise ValueError(
_(
"Duration of AK {ak_name} assigned by solver ({solver_duration} hours) "
"is less than the duration required by the slot ({slot_duration} hours)"
).format(
ak_name=slot.ak.name,
solver_duration=solver_duration,
slot_duration=slot.duration,
)
)
if slot.fixed:
solver_room = Room.objects.get(id=int(scheduled_slot["room_id"]))
if slot.room != solver_room:
raise ValueError(
_(
"Fixed AK {ak_name} assigned by solver to room {solver_room} "
"is fixed to room {slot_room}"
).format(
ak_name=slot.ak.name,
solver_room=solver_room.name,
slot_room=slot.room.name,
)
)
if slot.start != start_timeslot.start:
raise ValueError(
_(
"Fixed AK {ak_name} assigned by solver to start at {solver_start} "
"is fixed to start at {slot_start}"
).format(
ak_name=slot.ak.name,
solver_start=start_timeslot.start,
slot_start=slot.start,
)
)
else:
slot.room = Room.objects.get(id=int(scheduled_slot["room_id"]))
slot.start = start_timeslot.start
slot.save()
slots_updated += 1
return slots_updated
@property
def rooms(self):
"""Ordered queryset of all rooms associated to this event."""
return Room.objects.filter(event=self).order_by()
@property
def slots(self):
"""Ordered queryset of all AKSlots associated to this event."""
return AKSlot.objects.filter(event=self).order_by()
@property
def participants(self):
"""Ordered queryset of all participants associated to this event."""
return EventParticipant.objects.filter(event=self).order_by()
@property
def owners(self):
"""Ordered queryset of all AK owners associated to this event."""
return AKOwner.objects.filter(event=self).order_by()
class AKOwner(models.Model):
""" An AKOwner describes the person organizing/holding an AK.
"""
name = models.CharField(max_length=64, verbose_name=_('Nickname'), help_text=_('Name to identify an AK owner by'))
name = models.CharField(max_length=64, verbose_name=_('Nickname'),
validators=[no_quotation_marks_validator, slugable_validator],
help_text=_('Name to identify an AK owner by'))
slug = models.SlugField(max_length=64, blank=True, verbose_name=_('Slug'), help_text=_('Slug for URL generation'))
institution = models.CharField(max_length=128, blank=True, verbose_name=_('Institution'), help_text=_('Uni etc.'))
link = models.URLField(blank=True, verbose_name=_('Web Link'), help_text=_('Link to Homepage'))
......@@ -245,8 +616,8 @@ class AKCategory(models.Model):
description = models.TextField(blank=True, verbose_name=_("Description"),
help_text=_("Short description of this AK Category"))
present_by_default = models.BooleanField(blank=True, default=True, verbose_name=_("Present by default"),
help_text=_("Present AKs of this category by default "
"if AK owner did not specify whether this AK should be presented?"))
help_text=_("Present AKs of this category by default if AK owner did not "
"specify whether this AK should be presented?"))
event = models.ForeignKey(to=Event, on_delete=models.CASCADE, verbose_name=_('Event'),
help_text=_('Associated event'))
......@@ -260,6 +631,20 @@ class AKCategory(models.Model):
def __str__(self):
return self.name
@staticmethod
def create_category_optimizer_constraints(categories: Iterable["AKCategory"]) -> set[str]:
"""Create a set of constraint strings from an AKCategory iterable.
:param categories: The iterable of categories to derive the constraint strings from.
:return: A set of category constraint strings, i.e. strings of the form
'availability-cat-<cat.name>'.
:rtype: set of strings.
"""
return {
f"availability-cat-{cat.name}"
for cat in categories
}
class AKTrack(models.Model):
""" An AKTrack describes a set of semantically related AKs.
......@@ -328,8 +713,10 @@ class AKType(models.Model):
class AK(models.Model):
""" An AK is a slot-based activity to be scheduled during an event.
"""
name = models.CharField(max_length=256, verbose_name=_('Name'), help_text=_('Name of the AK'))
name = models.CharField(max_length=256, verbose_name=_('Name'), help_text=_('Name of the AK'),
validators=[no_quotation_marks_validator, slugable_validator])
short_name = models.CharField(max_length=64, blank=True, verbose_name=_('Short Name'),
validators=[no_quotation_marks_validator],
help_text=_('Name displayed in the schedule'))
description = models.TextField(blank=True, verbose_name=_('Description'), help_text=_('Description of the AK'))
......@@ -343,7 +730,7 @@ class AK(models.Model):
category = models.ForeignKey(to=AKCategory, on_delete=models.PROTECT, verbose_name=_('Category'),
help_text=_('Category of the AK'))
types = models.ManyToManyField(to=AKType, blank=True, verbose_name=_('Types'),
help_text=_("This AK is"))
help_text=_("This AK is"))
track = models.ForeignKey(to=AKTrack, blank=True, on_delete=models.SET_NULL, null=True, verbose_name=_('Track'),
help_text=_('Track the AK belongs to'))
......@@ -361,8 +748,8 @@ class AK(models.Model):
help_text=_('AKs that should precede this AK in the schedule'))
notes = models.TextField(blank=True, verbose_name=_('Organizational Notes'), help_text=_(
'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).'))
'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 = models.IntegerField(default=-1, verbose_name=_('Interest'), help_text=_('Expected number of people'))
interest_counter = models.IntegerField(default=0, verbose_name=_('Interest Counter'),
......@@ -400,7 +787,7 @@ class AK(models.Model):
availabilities = ', \n'.join(f'{a.simplified}' for a in Availability.objects.select_related('event')
.filter(ak=self))
detail_string = f"""{self.name}{" (R)" if self.reso else ""}:
{self.owners_list}
{_('Interest')}: {self.interest}"""
......@@ -435,7 +822,7 @@ class AK(models.Model):
Get a list of stringified representations of all owners
:return: list of owners
:rtype: List[str]
:rtype: list[str]
"""
return ", ".join(str(owner) for owner in self.owners.all())
......@@ -445,7 +832,7 @@ class AK(models.Model):
Get a list of stringified representations of all durations of associated slots
:return: list of durations
:rtype: List[str]
:rtype: list[str]
"""
return ", ".join(str(slot.duration_simplified) for slot in self.akslot_set.select_related('event').all())
......@@ -503,7 +890,7 @@ class AK(models.Model):
return reverse_lazy('submit:ak_detail', kwargs={'event_slug': self.event.slug, 'pk': self.id})
return self.edit_url
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
def save(self, *args, force_insert=False, force_update=False, using=None, update_fields=None):
# Auto-Generate Link if not set yet
if self.link == "":
link = self.event.base_url + self.name.replace(" ", "_")
......@@ -512,7 +899,8 @@ class AK(models.Model):
# Tell Django that we have updated the link field
if update_fields is not None:
update_fields = {"link"}.union(update_fields)
super().save(force_insert, force_update, using, update_fields)
super().save(*args,
force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
class Room(models.Model):
......@@ -550,6 +938,32 @@ class Room(models.Model):
def __str__(self):
return self.title
def get_time_constraints(self) -> list[str]:
"""Construct list of required time constraint labels."""
# local import to prevent cyclic import
# pylint: disable=import-outside-toplevel
from AKModel.availability.models import Availability
# check if room is available for the whole event
# -> no time constraint needs to be introduced
if Availability.is_event_covered(self.event, self.availabilities.all()):
time_constraints = []
else:
time_constraints = [f"availability-room-{self.pk}"]
return time_constraints
def get_fulfilled_room_constraints(self) -> list[str]:
"""Construct list of fulfilled room constraint labels."""
fulfilled_room_constraints = list(self.properties.values_list("name", flat=True))
fulfilled_room_constraints.append(f"fixed-room-{self.pk}")
if not any(constr.startswith("proxy") for constr in fulfilled_room_constraints):
fulfilled_room_constraints.append("no-proxy")
fulfilled_room_constraints.sort()
return fulfilled_room_constraints
class AKSlot(models.Model):
""" An AK Mapping matches an AK to a room during a certain time.
......@@ -629,7 +1043,7 @@ class AKSlot(models.Model):
def overlaps(self, other: "AKSlot"):
"""
Check wether two slots overlap
Check whether two slots overlap
:param other: second slot to compare with
:return: true if they overlap, false if not:
......@@ -637,13 +1051,88 @@ class AKSlot(models.Model):
"""
return self.start < other.end <= self.end or self.start <= other.start < self.end
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
def save(self, *args, force_insert=False, force_update=False, using=None, update_fields=None):
# Make sure duration is not longer than the event
if update_fields is None or 'duration' in update_fields:
event_duration = self.event.end - self.event.start
event_duration_hours = event_duration.days * 24 + event_duration.seconds // 3600
self.duration = min(self.duration, event_duration_hours)
super().save(force_insert, force_update, using, update_fields)
super().save(*args,
force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
def get_room_constraints(self) -> list[str]:
"""Construct list of required room constraint labels."""
room_constraints = list(self.ak.requirements.values_list("name", flat=True).order_by())
if self.fixed and self.room is not None:
room_constraints.append(f"fixed-room-{self.room.pk}")
if not any(constr.startswith("proxy") for constr in room_constraints):
room_constraints.append("no-proxy")
room_constraints.sort()
return room_constraints
def get_time_constraints(self) -> list[str]:
"""Construct list of required time constraint labels."""
# local import to prevent cyclic import
# pylint: disable=import-outside-toplevel
from AKModel.availability.models import Availability
def _owner_time_constraints(owner: AKOwner):
owner_avails = owner.availabilities.all()
if not owner_avails or Availability.is_event_covered(self.event, owner_avails):
return []
return [f"availability-person-{owner.pk}"]
# check if ak resp. owner is available for the whole event
# -> no time constraint needs to be introduced
if self.fixed and self.start is not None:
time_constraints = [f"fixed-akslot-{self.id}"]
elif not Availability.is_event_covered(self.event, self.ak.availabilities.all()):
time_constraints = [f"availability-ak-{self.ak.pk}"]
else:
time_constraints = []
if self.ak.reso:
time_constraints.append("resolution")
for owner in self.ak.owners.all():
time_constraints.extend(_owner_time_constraints(owner))
if self.ak.category:
category_constraints = AKCategory.create_category_optimizer_constraints([self.ak.category])
time_constraints.extend(category_constraints)
time_constraints.sort()
return time_constraints
@property
def export_duration(self) -> int:
"""Number of discrete export timeslots covered by this AKSlot."""
export_duration = self.duration / self.event.export_slot
# We need to return an int, so we round up.
# If the exact result for `export_duration` is an integer `k`,
# FLOP inaccuracies could yield `k + eps`. Then, rounding up
# would return `k + 1` instead of `k`. To avoid this, we subtract
# a small epsilon before rounding.
return math.ceil(export_duration - settings.EXPORT_CEIL_OFFSET_EPS)
@property
def type_names(self):
"""Ordered queryset of the names of all types of this slot's AK."""
return self.ak.types.values_list("name", flat=True).order_by()
@property
def conflict_pks(self) -> list[int]:
"""Ordered queryset of the PKs of all AKSlots that in conflict to this slot."""
conflict_slots = AKSlot.objects.filter(ak__in=self.ak.conflicts.all())
other_ak_slots = AKSlot.objects.filter(ak=self.ak).exclude(pk=self.pk)
return list((conflict_slots | other_ak_slots).values_list("pk", flat=True).order_by())
@property
def depencency_pks(self) -> list[int]:
"""Ordered queryset of the PKs of all AKSlots that this slot depends on."""
dependency_slots = AKSlot.objects.filter(ak__in=self.ak.prerequisites.all())
return list(dependency_slots.values_list("pk", flat=True).order_by())
class AKOrgaMessage(models.Model):
......@@ -678,6 +1167,7 @@ class ConstraintViolation(models.Model):
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
"""
class Meta:
verbose_name = _('Constraint Violation')
verbose_name_plural = _('Constraint Violations')
......@@ -694,7 +1184,7 @@ class ConstraintViolation(models.Model):
AK_CONFLICT_COLLISION = 'acc', _('AK Slot is scheduled at the same time as an AK listed as a conflict')
AK_BEFORE_PREREQUISITE = 'abp', _('AK Slot is scheduled before an AK listed as a prerequisite')
AK_AFTER_RESODEADLINE = 'aar', _(
'AK Slot for AK with intention to submit a resolution is scheduled after resolution deadline')
'AK Slot for AK with intention to submit a resolution is scheduled after resolution deadline')
AK_CATEGORY_MISMATCH = 'acm', _('AK Slot in a category is outside that categories availabilities')
AK_SLOT_COLLISION = 'asc', _('Two AK Slots for the same AK scheduled at the same time')
ROOM_CAPACITY_EXCEEDED = 'rce', _('Room does not have enough space for interest in scheduled AK Slot')
......@@ -895,6 +1385,7 @@ class DefaultSlot(models.Model):
Model representing a default slot,
i.e., a prefered slot to use for typical AKs in the schedule to guarantee enough breaks etc.
"""
class Meta:
verbose_name = _('Default Slot')
verbose_name_plural = _('Default Slots')
......@@ -907,7 +1398,8 @@ class DefaultSlot(models.Model):
help_text=_('Associated event'))
primary_categories = models.ManyToManyField(to=AKCategory, verbose_name=_('Primary categories'), blank=True,
help_text=_('Categories that should be assigned to this slot primarily'))
help_text=_(
'Categories that should be assigned to this slot primarily'))
@property
def start_simplified(self) -> str:
......@@ -939,3 +1431,123 @@ class DefaultSlot(models.Model):
def __str__(self):
return f"{self.event}: {self.start_simplified} - {self.end_simplified}"
class EventParticipant(models.Model):
""" A participant describes a person taking part in an event."""
class Meta:
verbose_name = _('Participant')
verbose_name_plural = _('Participants')
ordering = ['name']
name = models.CharField(max_length=64, blank=True, verbose_name=_('Nickname'),
help_text=_('Name to identify a participant by (in case of questions from the organizers)'))
institution = models.CharField(max_length=128, blank=True, verbose_name=_('Institution'), help_text=_('Uni etc.'))
event = models.ForeignKey(to=Event, on_delete=models.CASCADE, verbose_name=_('Event'),
help_text=_('Associated event'))
requirements = models.ManyToManyField(to=AKRequirement, blank=True, verbose_name=_('Requirements'),
help_text=_("Participant's Requirements"))
def __str__(self) -> str:
string = _("Anonymous {pk}").format(pk=self.pk) if not self.name else self.name
if self.institution:
string += f" ({self.institution})"
return string
@property
def availabilities(self):
"""
Get all availabilities associated to this EventParticipant
:return: availabilities
:rtype: QuerySet[Availability]
"""
return "Availability".objects.filter(participant=self)
def get_time_constraints(self) -> list[str]:
"""Construct list of required time constraint labels."""
# local import to prevent cyclic import
# pylint: disable=import-outside-toplevel
from AKModel.availability.models import Availability
avails = self.availabilities.all()
participant_required_prefs = AKPreference.objects.filter(
event=self.event,
participant=self,
preference=AKPreference.PreferenceLevel.REQUIRED,
).exists()
if (
avails
and not Availability.is_event_covered(self.event, avails)
and participant_required_prefs.exists()
):
# participant has restricted availability and is actually required for AKs
return [f"availability-participant-{self.pk}"]
return []
def get_room_constraints(self) -> list[str]:
"""Construct list of required room constraint labels."""
return list(self.requirements.values_list("name", flat=True).order_by())
@property
def export_preferences(self):
"""Preferences of this participant with positive score."""
return AKPreference.objects.filter(
participant=self, preference__gt=0
).order_by()
class AKPreference(models.Model):
"""Model representing the preference of a participant to an AK."""
class Meta:
verbose_name = _('AK Preference')
verbose_name_plural = _('AK Preferences')
unique_together = [['event', 'participant', 'slot']]
event = models.ForeignKey(to=Event, on_delete=models.CASCADE, verbose_name=_('Event'),
help_text=_('Associated event'))
participant = models.ForeignKey(to=EventParticipant, on_delete=models.CASCADE, verbose_name=_('Participant'),
help_text=_('Participant this preference belongs to'))
slot = models.ForeignKey(to=AKSlot, on_delete=models.CASCADE, verbose_name=_('AK Slot'),
help_text=_('AK Slot this preference belongs to'))
class PreferenceLevel(models.IntegerChoices):
"""
Possible preference values
"""
IGNORE = 0, _('Ignore')
PREFER = 1, _('Prefer')
STRONG_PREFER = 2, _("Strong prefer")
REQUIRED = 3, _("Required")
preference = models.PositiveSmallIntegerField(verbose_name=_('Preference'), choices=PreferenceLevel.choices,
help_text=_('Preference level for the AK'),
blank=False,
default=PreferenceLevel.IGNORE)
def __str__(self) -> str:
json_repr = json.dumps(
{
"ak_id": self.slot.pk,
"required": self.required,
"preference_score": self.preference_score,
}
)
return f"AKPreference: {json_repr}"
@property
def required(self) -> bool:
"""Whether this preference is a 'REQUIRED'"""
return self.preference == self.PreferenceLevel.REQUIRED
@property
def preference_score(self) -> int:
"""Score of this preference for the solver"""
return self.preference if self.preference != self.PreferenceLevel.REQUIRED else -1
from rest_framework import serializers
from AKModel.models import AK, Room, AKSlot, AKTrack, AKCategory, AKOwner
from AKModel.models import AK, AKCategory, AKOwner, AKSlot, AKTrack, Room
class AKOwnerSerializer(serializers.ModelSerializer):
......
......@@ -5,10 +5,21 @@ from django.contrib.auth import get_user_model
from django.contrib.messages import get_messages
from django.contrib.messages.storage.base import Message
from django.test import TestCase
from django.urls import reverse_lazy, reverse
from AKModel.models import Event, AKOwner, AKCategory, AKTrack, AKRequirement, AK, Room, AKSlot, AKOrgaMessage, \
ConstraintViolation, DefaultSlot
from django.urls import reverse, reverse_lazy
from AKModel.models import (
AK,
AKCategory,
AKOrgaMessage,
AKOwner,
AKRequirement,
AKSlot,
AKTrack,
ConstraintViolation,
DefaultSlot,
Event,
Room,
)
class BasicViewTests:
......@@ -29,9 +40,10 @@ class BasicViewTests:
since the test framework does not understand the concept of abstract test definitions and would handle this class
as real test case otherwise, distorting the test results.
"""
# pylint: disable=no-member
VIEWS = []
APP_NAME = ''
APP_NAME = ""
VIEWS_STAFF_ONLY = []
EDIT_TESTCASES = []
......@@ -41,16 +53,26 @@ class BasicViewTests:
"""
user_model = get_user_model()
self.staff_user = user_model.objects.create(
username='Test Staff User', email='teststaff@example.com', password='staffpw',
is_staff=True, is_active=True
username="Test Staff User",
email="teststaff@example.com",
password="staffpw",
is_staff=True,
is_active=True,
)
self.admin_user = user_model.objects.create(
username='Test Admin User', email='testadmin@example.com', password='adminpw',
is_staff=True, is_superuser=True, is_active=True
username="Test Admin User",
email="testadmin@example.com",
password="adminpw",
is_staff=True,
is_superuser=True,
is_active=True,
)
self.deactivated_user = user_model.objects.create(
username='Test Deactivated User', email='testdeactivated@example.com', password='deactivatedpw',
is_staff=True, is_active=False
username="Test Deactivated User",
email="testdeactivated@example.com",
password="deactivatedpw",
is_staff=True,
is_active=False,
)
def _name_and_url(self, view_name):
......@@ -62,7 +84,9 @@ class BasicViewTests:
:return: full view name with prefix if applicable, url of the view
:rtype: str, str
"""
view_name_with_prefix = f"{self.APP_NAME}:{view_name[0]}" if self.APP_NAME != "" else view_name[0]
view_name_with_prefix = (
f"{self.APP_NAME}:{view_name[0]}" if self.APP_NAME != "" else view_name[0]
)
url = reverse(view_name_with_prefix, kwargs=view_name[1])
return view_name_with_prefix, url
......@@ -74,7 +98,7 @@ class BasicViewTests:
:param expected_message: message that should be shown
:param msg_prefix: prefix for the error message when test fails
"""
messages:List[Message] = list(get_messages(response.wsgi_request))
messages: List[Message] = list(get_messages(response.wsgi_request))
msg_count = "No message shown to user"
msg_content = "Wrong message, expected '{expected_message}'"
......@@ -95,10 +119,16 @@ class BasicViewTests:
view_name_with_prefix, url = self._name_and_url(view_name)
try:
response = self.client.get(url)
self.assertEqual(response.status_code, 200, msg=f"{view_name_with_prefix} ({url}) broken")
except Exception: # pylint: disable=broad-exception-caught
self.fail(f"An error occurred during rendering of {view_name_with_prefix} ({url}):"
f"\n\n{traceback.format_exc()}")
self.assertEqual(
response.status_code,
200,
msg=f"{view_name_with_prefix} ({url}) broken",
)
except Exception: # pylint: disable=broad-exception-caught
self.fail(
f"An error occurred during rendering of {view_name_with_prefix} ({url}):"
f"\n\n{traceback.format_exc()}"
)
def test_access_control_staff_only(self):
"""
......@@ -107,11 +137,16 @@ class BasicViewTests:
# Not logged in? Views should not be visible
self.client.logout()
for view_name_info in self.VIEWS_STAFF_ONLY:
expected_response_code = 302 if len(view_name_info) == 2 else view_name_info[2]
expected_response_code = (
302 if len(view_name_info) == 2 else view_name_info[2]
)
view_name_with_prefix, url = self._name_and_url(view_name_info)
response = self.client.get(url)
self.assertEqual(response.status_code, expected_response_code,
msg=f"{view_name_with_prefix} ({url}) accessible by non-staff")
self.assertEqual(
response.status_code,
expected_response_code,
msg=f"{view_name_with_prefix} ({url}) accessible by non-staff",
)
# Logged in? Views should be visible
self.client.force_login(self.staff_user)
......@@ -119,20 +154,30 @@ class BasicViewTests:
view_name_with_prefix, url = self._name_and_url(view_name_info)
try:
response = self.client.get(url)
self.assertEqual(response.status_code, 200,
msg=f"{view_name_with_prefix} ({url}) should be accessible for staff (but isn't)")
self.assertEqual(
response.status_code,
200,
msg=f"{view_name_with_prefix} ({url}) should be accessible for staff (but isn't)",
)
except Exception: # pylint: disable=broad-exception-caught
self.fail(f"An error occurred during rendering of {view_name_with_prefix} ({url}):"
f"\n\n{traceback.format_exc()}")
self.fail(
f"An error occurred during rendering of {view_name_with_prefix} ({url}):"
f"\n\n{traceback.format_exc()}"
)
# Disabled user? Views should not be visible
self.client.force_login(self.deactivated_user)
for view_name_info in self.VIEWS_STAFF_ONLY:
expected_response_code = 302 if len(view_name_info) == 2 else view_name_info[2]
expected_response_code = (
302 if len(view_name_info) == 2 else view_name_info[2]
)
view_name_with_prefix, url = self._name_and_url(view_name_info)
response = self.client.get(url)
self.assertEqual(response.status_code, expected_response_code,
msg=f"{view_name_with_prefix} ({url}) still accessible for deactivated user")
self.assertEqual(
response.status_code,
expected_response_code,
msg=f"{view_name_with_prefix} ({url}) still accessible for deactivated user",
)
def _to_sendable_value(self, val):
"""
......@@ -182,16 +227,26 @@ class BasicViewTests:
self.client.logout()
response = self.client.get(url)
self.assertEqual(response.status_code, 200, msg=f"{name}: Could not load edit form via GET ({url})")
self.assertEqual(
response.status_code,
200,
msg=f"{name}: Could not load edit form via GET ({url})",
)
form = response.context[form_name]
data = {k:self._to_sendable_value(v) for k,v in form.initial.items()}
data = {k: self._to_sendable_value(v) for k, v in form.initial.items()}
response = self.client.post(url, data=data)
if expected_code == 200:
self.assertEqual(response.status_code, 200, msg=f"{name}: Did not return 200 ({url}")
self.assertEqual(
response.status_code, 200, msg=f"{name}: Did not return 200 ({url}"
)
elif expected_code == 302:
self.assertRedirects(response, target_url, msg_prefix=f"{name}: Did not redirect ({url} -> {target_url}")
self.assertRedirects(
response,
target_url,
msg_prefix=f"{name}: Did not redirect ({url} -> {target_url}",
)
if expected_message != "":
self._assert_message(response, expected_message, msg_prefix=f"{name}")
......@@ -200,30 +255,42 @@ class ModelViewTests(BasicViewTests, TestCase):
"""
Basic view test cases for views from AKModel plus some custom tests
"""
fixtures = ['model.json']
fixtures = ["model.json"]
ADMIN_MODELS = [
(Event, 'event'), (AKOwner, 'akowner'), (AKCategory, 'akcategory'), (AKTrack, 'aktrack'),
(AKRequirement, 'akrequirement'), (AK, 'ak'), (Room, 'room'), (AKSlot, 'akslot'),
(AKOrgaMessage, 'akorgamessage'), (ConstraintViolation, 'constraintviolation'),
(DefaultSlot, 'defaultslot')
(Event, "event"),
(AKOwner, "akowner"),
(AKCategory, "akcategory"),
(AKTrack, "aktrack"),
(AKRequirement, "akrequirement"),
(AK, "ak"),
(Room, "room"),
(AKSlot, "akslot"),
(AKOrgaMessage, "akorgamessage"),
(ConstraintViolation, "constraintviolation"),
(DefaultSlot, "defaultslot"),
]
VIEWS_STAFF_ONLY = [
('admin:index', {}),
('admin:event_status', {'event_slug': 'kif42'}),
('admin:event_requirement_overview', {'event_slug': 'kif42'}),
('admin:ak_csv_export', {'event_slug': 'kif42'}),
('admin:ak_wiki_export', {'slug': 'kif42'}),
('admin:ak_delete_orga_messages', {'event_slug': 'kif42'}),
('admin:ak_slide_export', {'event_slug': 'kif42'}),
('admin:default-slots-editor', {'event_slug': 'kif42'}),
('admin:room-import', {'event_slug': 'kif42'}),
('admin:new_event_wizard_start', {}),
("admin:index", {}),
("admin:event_status", {"event_slug": "kif42"}),
("admin:event_requirement_overview", {"event_slug": "kif42"}),
("admin:ak_csv_export", {"event_slug": "kif42"}),
("admin:ak_wiki_export", {"slug": "kif42"}),
("admin:ak_delete_orga_messages", {"event_slug": "kif42"}),
("admin:ak_slide_export", {"event_slug": "kif42"}),
("admin:default-slots-editor", {"event_slug": "kif42"}),
("admin:room-import", {"event_slug": "kif42"}),
("admin:new_event_wizard_start", {}),
]
EDIT_TESTCASES = [
{'view': 'admin:default-slots-editor', 'kwargs': {'event_slug': 'kif42'}, "admin": True},
{
"view": "admin:default-slots-editor",
"kwargs": {"event_slug": "kif42"},
"admin": True,
},
]
def test_admin(self):
......@@ -234,24 +301,32 @@ class ModelViewTests(BasicViewTests, TestCase):
for model in self.ADMIN_MODELS:
# Special treatment for a subset of views (where we exchanged default functionality, e.g., create views)
if model[1] == "event":
_, url = self._name_and_url(('admin:new_event_wizard_start', {}))
_, url = self._name_and_url(("admin:new_event_wizard_start", {}))
elif model[1] == "room":
_, url = self._name_and_url(('admin:room-new', {}))
_, url = self._name_and_url(("admin:room-new", {}))
# Otherwise, just call the creation form view
else:
_, url = self._name_and_url((f'admin:AKModel_{model[1]}_add', {}))
_, url = self._name_and_url((f"admin:AKModel_{model[1]}_add", {}))
response = self.client.get(url)
self.assertEqual(response.status_code, 200, msg=f"Add form for model {model[1]} ({url}) broken")
self.assertEqual(
response.status_code,
200,
msg=f"Add form for model {model[1]} ({url}) broken",
)
for model in self.ADMIN_MODELS:
# Test the update view using the first existing instance of each model
m = model[0].objects.first()
if m is not None:
_, url = self._name_and_url(
(f'admin:AKModel_{model[1]}_change', {'object_id': m.pk})
(f"admin:AKModel_{model[1]}_change", {"object_id": m.pk})
)
response = self.client.get(url)
self.assertEqual(response.status_code, 200, msg=f"Edit form for model {model[1]} ({url}) broken")
self.assertEqual(
response.status_code,
200,
msg=f"Edit form for model {model[1]} ({url}) broken",
)
def test_wiki_export(self):
"""
......@@ -260,17 +335,27 @@ class ModelViewTests(BasicViewTests, TestCase):
"""
self.client.force_login(self.admin_user)
export_url = reverse_lazy("admin:ak_wiki_export", kwargs={'slug': 'kif42'})
export_url = reverse_lazy("admin:ak_wiki_export", kwargs={"slug": "kif42"})
response = self.client.get(export_url)
self.assertEqual(response.status_code, 200, "Export not working at all")
export_count = 0
for _, aks in response.context["categories_with_aks"]:
for ak in aks:
self.assertEqual(ak.include_in_export, True,
f"AK with export flag set to False (pk={ak.pk}) included in export")
self.assertNotEqual(ak.pk, 1, "AK known to be excluded from export (PK 1) included in export")
self.assertEqual(
ak.include_in_export,
True,
f"AK with export flag set to False (pk={ak.pk}) included in export",
)
self.assertNotEqual(
ak.pk,
1,
"AK known to be excluded from export (PK 1) included in export",
)
export_count += 1
self.assertEqual(export_count, AK.objects.filter(event_id=2, include_in_export=True).count(),
"Wiki export contained the wrong number of AKs")
self.assertEqual(
export_count,
AK.objects.filter(event_id=2, include_in_export=True).count(),
"Wiki export contained the wrong number of AKs",
)
......@@ -6,7 +6,8 @@ from rest_framework.routers import DefaultRouter
import AKModel.views.api
from AKModel.views.manage import ExportSlidesView, PlanPublishView, PlanUnpublishView, DefaultSlotEditorView, \
AKsByUserView
from AKModel.views.ak import AKRequirementOverview, AKCSVExportView, AKWikiExportView, AKMessageDeleteView
from AKModel.views.ak import AKRequirementOverview, AKCSVExportView, AKWikiExportView, \
AKMessageDeleteView
from AKModel.views.event_wizard import NewEventWizardStartView, NewEventWizardPrepareImportView, \
NewEventWizardImportView, NewEventWizardActivateView, NewEventWizardFinishView, NewEventWizardSettingsView
from AKModel.views.room import RoomBatchCreationView
......@@ -44,6 +45,11 @@ if apps.is_installed("AKSubmission"):
from AKSubmission.api import increment_interest_counter
extra_paths.append(path('api/ak/<pk>/indicate-interest/', increment_interest_counter, name='submission-ak-indicate-interest'))
# If AKSolverInterface is active, register additional API endpoints
if apps.is_installed("AKSolverInterface"):
from AKSolverInterface.api import ExportEventForSolverViewSet
api_router.register("solver-export", ExportEventForSolverViewSet, basename="solver-export")
event_specific_paths = [
path('api/', include(api_router.urls), name='api'),
]
......
......@@ -4,6 +4,7 @@ import os
import tempfile
from itertools import zip_longest
from django.contrib import messages
from django.db.models.functions import Now
from django.utils.dateparse import parse_datetime
......@@ -58,7 +59,7 @@ class ExportSlidesView(EventSlugMixin, IntermediateAdminView):
Create a list of tuples cosisting of an AK and a list of upcoming AKs (list length depending on setting)
"""
next_aks_list = zip_longest(*[ak_list[i + 1:] for i in range(NEXT_AK_LIST_LENGTH)], fillvalue=None)
return [(ak, next_aks) for ak, next_aks in zip_longest(ak_list, next_aks_list, fillvalue=[])]
return list(zip_longest(ak_list, next_aks_list, fillvalue=[]))
# Get all relevant AKs (wishes separately, and either all AKs or only those who should directly or indirectly
# be presented when restriction setting was chosen)
......
......@@ -152,6 +152,17 @@ class EventAKsWidget(TemplateStatusWidget):
},
]
)
if apps.is_installed("AKSolverInterface"):
actions.extend([
{
"text": _("Export AKs as JSON"),
"url": reverse_lazy("admin:ak_json_export", kwargs={"event_slug": context["event"].slug}),
},
{
"text": _("Import AK schedule from JSON"),
"url": reverse_lazy("admin:ak_schedule_json_import", kwargs={"event_slug": context["event"].slug}),
},
])
return actions
......