Skip to content
Snippets Groups Projects
Commit 522ae398 authored by Nadja Geisler's avatar Nadja Geisler :sunny:
Browse files

Merge branch 'feature-scheduler-improve' into 'main'

Improve scheduler

See merge request kif/akplanning!146
parents 9f89e85a 42e4a3ac
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......@@ -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):
......
......@@ -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"
......
......@@ -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');
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment