diff --git a/AKScheduling/api.py b/AKScheduling/api.py index e54e75fd0ea36eb07f2dbe581f2761d5dcae7278..84b629224b69119acd62cc8ca5dafcae32a8684d 100644 --- a/AKScheduling/api.py +++ b/AKScheduling/api.py @@ -91,8 +91,8 @@ class EventSerializer(serializers.ModelSerializer): roomId = serializers.IntegerField(source='room.pk') def update(self, instance, validated_data): - start = timezone.make_aware(timezone.make_naive(validated_data.get('start', instance.start)), instance.event.timezone) - end = timezone.make_aware(timezone.make_naive(validated_data.get('end', instance.end)), instance.event.timezone) + start = timezone.make_aware(timezone.make_naive(validated_data.get('start')), instance.event.timezone) + end = timezone.make_aware(timezone.make_naive(validated_data.get('end')), instance.event.timezone) instance.start = start instance.room = get_object_or_404(Room, pk=validated_data.get('room')["pk"]) diff = end - start diff --git a/AKScheduling/templates/admin/AKScheduling/scheduling.html b/AKScheduling/templates/admin/AKScheduling/scheduling.html index a17cb88b4c9910a3753b384230d60112f28c730b..1c45be592c1710297096fcc1127eb70ed31d9420 100644 --- a/AKScheduling/templates/admin/AKScheduling/scheduling.html +++ b/AKScheduling/templates/admin/AKScheduling/scheduling.html @@ -2,6 +2,7 @@ {% load tags_AKModel %} {% load i18n %} +{% load l10n %} {% load tz %} {% load static %} {% load tags_AKPlan %} @@ -19,6 +20,13 @@ <script src="{% static locale_file %}"></script> {% endwith %} + <style> + .unscheduled-slot { + cursor: move; + + } + </style> + <script> document.addEventListener('DOMContentLoaded', function () { // CSRF Protection/Authentication @@ -62,7 +70,7 @@ // Calendar var planEl = document.getElementById('planCalendar'); - var plan = new FullCalendar.Calendar(planEl, { + plan = new FullCalendar.Calendar(planEl, { timeZone: '{{ event.timezone }}', headerToolbar : { left: 'today prev,next', @@ -118,7 +126,12 @@ // React to event changes (moving or change of duration) eventChange: updateEvent, + eventReceive: updateEvent, editable: true, + dropable: true, + drop: function(info) { + info.draggedEl.parentNode.removeChild(info.draggedEl); + }, allDaySlot: false, nowIndicator: true, eventTextColor: '#fff', @@ -160,7 +173,17 @@ {% block content %} - <div id="planCalendar" style="margin-bottom: 50px;"></div> + <div class="row" style="margin-bottom: 50px;"> + <div class="col-md-10 col-lg-11"> + <div id="planCalendar" ></div> + </div> + <div class="col-md-2 col-lg-1" id="unscheduled-slots"> + {% for slot in slots_unscheduled %} + <div class="unscheduled-slot badge badge-primary" data-event='{ "title": "{{ slot.ak.short_name }}", "duration": {"hours": "{{ slot.duration|unlocalize }}"}, "description": "{{ slot.ak.name }}", "slotID": "{{ slot.pk }}"}'>{{ slot.ak.short_name }} ({{ slot.duration }} h)</div> + {% endfor %} + </div> + </div> + <a href="{% url 'admin:event_status' event.slug %}">{% trans "Event Status" %}</a> {% endblock %} diff --git a/AKScheduling/views.py b/AKScheduling/views.py index c0649ab78f3bf7d57d392b4ab936419f0e0d9e7e..6bae0a318998c1ed7dcc173841e073a549299f92 100644 --- a/AKScheduling/views.py +++ b/AKScheduling/views.py @@ -23,7 +23,10 @@ class UnscheduledSlotsAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView): template_name = "admin/AKScheduling/scheduling.html" model = AKSlot - context_object_name = "akslots" + context_object_name = "slots_unscheduled" + + def get_queryset(self): + return super().get_queryset().filter(start__isnull=True) def get_context_data(self, *, object_list=None, **kwargs): context = super().get_context_data(object_list=object_list, **kwargs)