diff --git a/AKModel/serializers.py b/AKModel/serializers.py index 7993b6223e44cd219eb5317705a69a5b32e9f325..8dbbb4eafa1c658f63de40d27986200e8de3552f 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/api.py b/AKScheduling/api.py index 2052403076c2e88c7162b3d1544b93e4d4c2af06..fb8db200795c14650191ce49f23749d1e3eb4a52 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): diff --git a/AKScheduling/locale/de_DE/LC_MESSAGES/django.po b/AKScheduling/locale/de_DE/LC_MESSAGES/django.po index 6326be76f8a6be3468014eb86e93b9e74012430d..129710e3708bd298add7c5a3b2bfcb44e4ac934f 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" diff --git a/AKScheduling/templates/admin/AKScheduling/scheduling.html b/AKScheduling/templates/admin/AKScheduling/scheduling.html index fc07b69d0823bfb9cff37fd5425def3075b4f2fc..05d37a38b284134d8776a6c9b6d8bd5bfa523c96 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); } @@ -257,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'); diff --git a/AKSubmission/forms.py b/AKSubmission/forms.py index ccd7398b5f40755859244f4f49668124f355cfb2..ed3eacfb11490f302a8cc9384cdccaf864e9f1d3 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