From 95ee00c2a4064bd38d0467d28ce344a6b24b6ba7 Mon Sep 17 00:00:00 2001
From: "N. Geisler" <ngeisler@fachschaft.informatik.tu-darmstadt.de>
Date: Wed, 4 Nov 2020 23:00:21 +0100
Subject: [PATCH 1/2] add background color acc. to category to scheduling
 interface

---
 AKScheduling/templates/admin/AKScheduling/scheduling.html | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/AKScheduling/templates/admin/AKScheduling/scheduling.html b/AKScheduling/templates/admin/AKScheduling/scheduling.html
index 1c45be59..bf56707c 100644
--- a/AKScheduling/templates/admin/AKScheduling/scheduling.html
+++ b/AKScheduling/templates/admin/AKScheduling/scheduling.html
@@ -175,11 +175,14 @@
 
     <div class="row" style="margin-bottom: 50px;">
         <div class="col-md-10 col-lg-11">
-            <div id="planCalendar" ></div>
+            <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>
+                <div class="unscheduled-slot badge badge-primary" style='background-color: {{ slot.ak.category.color }}'
+                     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>
-- 
GitLab


From fae6fb6bb844c5ea82241988fbb5a7972efe6afa Mon Sep 17 00:00:00 2001
From: "N. Geisler" <ngeisler@fachschaft.informatik.tu-darmstadt.de>
Date: Wed, 4 Nov 2020 23:38:35 +0100
Subject: [PATCH 2/2] more information in scheduling calendar

---
 AKModel/models.py                             | 10 +++++
 AKScheduling/api.py                           |  4 +-
 .../admin/AKScheduling/scheduling.html        | 43 +++++++++++--------
 3 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/AKModel/models.py b/AKModel/models.py
index 5a257cd5..08cb831a 100644
--- a/AKModel/models.py
+++ b/AKModel/models.py
@@ -245,6 +245,16 @@ class AK(models.Model):
             return self.short_name
         return self.name
 
+    @property
+    def details(self):
+        return f"""{self.name}{" (R)" if self.reso else ""}:
+        
+        {self.owners_list}
+
+        {_("Requirements")}: {", ".join(str(r) for r in self.requirements.all())}  
+        {_("Conflicts")}: {", ".join(str(c) for c in self.conflicts.all())}  
+        {_("Prerequisites")}: {", ".join(str(p) for p in self.prerequisites.all())}"""
+
     @property
     def owners_list(self):
         return ", ".join(str(owner) for owner in self.owners.all())
diff --git a/AKScheduling/api.py b/AKScheduling/api.py
index 84b62922..3601b551 100644
--- a/AKScheduling/api.py
+++ b/AKScheduling/api.py
@@ -42,8 +42,8 @@ class EventsView(LoginRequiredMixin, EventSlugMixin, ListView):
         return JsonResponse(
             [{
                 "slotID": slot.pk,
-                "title": slot.ak.short_name,
-                "description": slot.ak.name,
+                "title": f'{slot.ak.short_name}: \n{slot.ak.owners_list}',
+                "description": slot.ak.details,
                 "resourceId": slot.room.id,
                 "start": timezone.localtime(slot.start, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"),
                 "end": timezone.localtime(slot.end, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"),
diff --git a/AKScheduling/templates/admin/AKScheduling/scheduling.html b/AKScheduling/templates/admin/AKScheduling/scheduling.html
index bf56707c..99b3ddde 100644
--- a/AKScheduling/templates/admin/AKScheduling/scheduling.html
+++ b/AKScheduling/templates/admin/AKScheduling/scheduling.html
@@ -7,7 +7,7 @@
 {% load static %}
 {% load tags_AKPlan %}
 
-{% block title %}{% trans "Scheduling for" %} {{event}}{% endblock %}
+{% block title %}{% trans "Scheduling for" %} {{ event }}{% endblock %}
 
 {% block extrahead %}
     {{ block.super }}
@@ -21,10 +21,14 @@
     {% endwith %}
 
     <style>
-    .unscheduled-slot {
-        cursor: move;
+        .unscheduled-slot {
+            cursor: move;
 
-    }
+        }
+
+        .fc-v-event, .tooltip {
+            white-space: pre-line;
+        }
     </style>
 
     <script>
@@ -45,14 +49,16 @@
                 }
                 return cookieValue;
             }
+
             const csrftoken = getCookie('csrftoken');
 
             function csrfSafeMethod(method) {
                 // these HTTP methods do not require CSRF protection
                 return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
             }
+
             $.ajaxSetup({
-                beforeSend: function(xhr, settings) {
+                beforeSend: function (xhr, settings) {
                     if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                         xhr.setRequestHeader("X-CSRFToken", csrftoken);
                     }
@@ -64,7 +70,7 @@
             var containerEl = document.getElementById('unscheduled-slots');
             new FullCalendar.Draggable(containerEl, {
                 itemSelector: '.unscheduled-slot',
-              });
+            });
 
 
             // Calendar
@@ -72,7 +78,7 @@
 
             plan = new FullCalendar.Calendar(planEl, {
                 timeZone: '{{ event.timezone }}',
-                headerToolbar : {
+                headerToolbar: {
                     left: 'today prev,next',
                     center: 'title',
                     right: 'resourceTimelineDayVert,resourceTimelineDayHoriz,resourceTimelineEventVert,resourceTimelineEventHoriz'
@@ -115,12 +121,12 @@
                     }
                 },
                 // Show full AK title as tooltip for each AK (needs to be removed and newly placed when AK is moved)
-                eventDidMount : function(info) {
-                    if(info.event.extendedProps.description !== undefined) {
+                eventDidMount: function (info) {
+                    if (info.event.extendedProps.description !== undefined) {
                         $(info.el).tooltip({title: info.event.extendedProps.description, trigger: 'hover'});
                     }
                 },
-                eventWillUnmount : function(info) {
+                eventWillUnmount: function (info) {
                     $(info.el).tooltip('dispose');
                 },
 
@@ -129,7 +135,7 @@
                 eventReceive: updateEvent,
                 editable: true,
                 dropable: true,
-                drop: function(info) {
+                drop: function (info) {
                     info.draggedEl.parentNode.removeChild(info.draggedEl);
                 },
                 allDaySlot: false,
@@ -140,9 +146,9 @@
                 resourceAreaHeaderContent: '{% trans "Room" %}',
                 resources: '{% url "model:scheduling-resources-list" event_slug=event.slug %}',
                 eventSources: [
-                        '{% url "model:scheduling-events" event_slug=event.slug %}',
-                        '{% url "model:scheduling-room-availabilities" event_slug=event.slug %}'
-                    ],
+                    '{% url "model:scheduling-events" event_slug=event.slug %}',
+                    '{% url "model:scheduling-room-availabilities" event_slug=event.slug %}'
+                ],
                 schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
                 dayMinWidth: 100,
             });
@@ -160,10 +166,11 @@
                         end: plan.formatIso(changeInfo.event.end),
                         roomId: room.id,
                     },
-                    success: function(response) {},
-                    error: function(response) {
+                    success: function (response) {
+                    },
+                    error: function (response) {
                         changeInfo.revert();
-                        alert("ERROR. Did not update "+changeInfo.event.title)
+                        alert("ERROR. Did not update " + changeInfo.event.title)
                     }
                 });
             }
@@ -181,7 +188,7 @@
             {% for slot in slots_unscheduled %}
                 <div class="unscheduled-slot badge badge-primary" style='background-color: {{ slot.ak.category.color }}'
                      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)
+                    ({{ slot.duration }} h)<br>{{ slot.ak.owners_list }}
                 </div>
             {% endfor %}
         </div>
-- 
GitLab