From 51e7c8a35c95345c914ed5e2b4aa8904970aff9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?=
 <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de>
Date: Sat, 3 Dec 2022 20:29:57 +0100
Subject: [PATCH 1/5] Order rooms in scheduler alphabetically

---
 AKScheduling/api.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/AKScheduling/api.py b/AKScheduling/api.py
index 20524030..fb8db200 100644
--- a/AKScheduling/api.py
+++ b/AKScheduling/api.py
@@ -29,7 +29,7 @@ class ResourcesViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListMod
     serializer_class = ResourceSerializer
 
     def get_queryset(self):
-        return Room.objects.filter(event=self.event)
+        return Room.objects.filter(event=self.event).order_by('location', 'name')
 
 
 class EventsView(LoginRequiredMixin, EventSlugMixin, ListView):
-- 
GitLab


From 5bd354b69026bf18695bb42bd55c34841fa7ce33 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?=
 <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de>
Date: Sat, 3 Dec 2022 20:35:06 +0100
Subject: [PATCH 2/5] Improve violation count badge in scheduler

Show total count of violations as number, but only mark in orange if there are any violations that are not manually resolved already
---
 .../admin/AKScheduling/scheduling.html         | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/AKScheduling/templates/admin/AKScheduling/scheduling.html b/AKScheduling/templates/admin/AKScheduling/scheduling.html
index fc07b69d..5d15411c 100644
--- a/AKScheduling/templates/admin/AKScheduling/scheduling.html
+++ b/AKScheduling/templates/admin/AKScheduling/scheduling.html
@@ -196,16 +196,17 @@
             const cv_callback_success = function(response) {
                let table_html = '';
 
-               if(response.length > 0) {
-                   // Update violation count badge
-                   $('#violationCountBadge').html(response.length).removeClass('badge-success').addClass('badge-warning');
+               let unresolved_violations_count = 0;
 
+               if(response.length > 0) {
                    // Update violations table
                    for(let i=0;i<response.length;i++) {
                        if(response[i].manually_resolved)
                            table_html += '<tr class="text-muted"><td class="nowrap">{% fa5_icon "check" "fas" %} ';
-                       else
+                       else {
                            table_html += '<tr><td>';
+                           unresolved_violations_count++;
+                       }
 
                        if(response[i].level_display==='{% trans "Violation" %}')
                            table_html += '{% fa5_icon "exclamation-triangle" "fas" %}';
@@ -217,13 +218,16 @@
                    }
                }
                else {
-                   // Update violation count badge
-                   $('#violationCountBadge').html(0).removeClass('badge-warning').addClass('badge-success');
-
                    // Update violations table
                    table_html ='<tr class="text-muted"><td colspan="2" class="text-center">{% trans "No violations" %}</td></tr>'
                }
 
+               // Update violation count badge
+                if(unresolved_violations_count > 0)
+                    $('#violationCountBadge').html(response.length).removeClass('badge-success').addClass('badge-warning');
+                else
+                    $('#violationCountBadge').html(0).removeClass('badge-warning').addClass('badge-success');
+
                // Show violation list (potentially empty) in violations table
                $('#violationsTableBody').html(table_html);
             }
-- 
GitLab


From 45ed45f88c5a95a3a40f625db208b6d5f08a7abc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?=
 <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de>
Date: Sat, 3 Dec 2022 21:54:24 +0100
Subject: [PATCH 3/5] Fix typo in translation

---
 AKScheduling/locale/de_DE/LC_MESSAGES/django.po | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/AKScheduling/locale/de_DE/LC_MESSAGES/django.po b/AKScheduling/locale/de_DE/LC_MESSAGES/django.po
index 6326be76..129710e3 100644
--- a/AKScheduling/locale/de_DE/LC_MESSAGES/django.po
+++ b/AKScheduling/locale/de_DE/LC_MESSAGES/django.po
@@ -153,7 +153,7 @@ msgstr "Raum"
 
 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:261
 msgid "Unscheduled"
-msgstr "Micht gescheduled"
+msgstr "Nicht gescheduled"
 
 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:286
 msgid "Level"
-- 
GitLab


From 4cb30c335b32230eb56aabc671611866364568b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?=
 <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de>
Date: Sat, 3 Dec 2022 23:06:57 +0100
Subject: [PATCH 4/5] Fix timezone-caused offset when directly creating a new
 slot in scheduler

---
 AKModel/serializers.py                                   | 9 +++++++++
 .../templates/admin/AKScheduling/scheduling.html         | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/AKModel/serializers.py b/AKModel/serializers.py
index 7993b622..8dbbb4ea 100644
--- a/AKModel/serializers.py
+++ b/AKModel/serializers.py
@@ -37,3 +37,12 @@ class AKSlotSerializer(serializers.ModelSerializer):
     class Meta:
         model = AKSlot
         fields = '__all__'
+
+    treat_as_local = serializers.BooleanField(required=False, default=False, write_only=True)
+
+    def create(self, validated_data:dict):
+        if validated_data['treat_as_local']:
+            validated_data['start'] = validated_data['start'].replace(tzinfo=None).astimezone(
+                validated_data['event'].timezone)
+        del validated_data['treat_as_local']
+        return super().create(validated_data)
diff --git a/AKScheduling/templates/admin/AKScheduling/scheduling.html b/AKScheduling/templates/admin/AKScheduling/scheduling.html
index 5d15411c..05d37a38 100644
--- a/AKScheduling/templates/admin/AKScheduling/scheduling.html
+++ b/AKScheduling/templates/admin/AKScheduling/scheduling.html
@@ -261,7 +261,8 @@
                             duration: $('#id_duration').val(),
                             room: $('#id_room').val(),
                             ak: ak,
-                            event: "{{ event.pk }}"
+                            event: "{{ event.pk }}",
+                            treat_as_local: true,
                         },
                         success: function (response) {
                            $('#newAKSlotModal').modal('hide');
-- 
GitLab


From 42e4a3ac981a974c60d22d91f97e4f62edecf09f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?=
 <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de>
Date: Sat, 3 Dec 2022 23:07:20 +0100
Subject: [PATCH 5/5] Replace usage of deprecated translation method

---
 AKSubmission/forms.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/AKSubmission/forms.py b/AKSubmission/forms.py
index ccd7398b..ed3eacfb 100644
--- a/AKSubmission/forms.py
+++ b/AKSubmission/forms.py
@@ -3,7 +3,7 @@ import re
 
 from django import forms
 from django.core.exceptions import ValidationError
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
 
 from AKModel.availability.forms import AvailabilitiesFormMixin
 from AKModel.availability.models import Availability
-- 
GitLab