From d6a755c95e176ef494c130babe6e47bc6f776515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?= <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de> Date: Wed, 4 Mar 2020 00:57:15 +0100 Subject: [PATCH] Move event & room encoding and add more information to visualization Move encoding to own files that can be included Add url for linking to detail page to event encoding Add color coding for category and track to event encoding Introduce room hierarchy (building + room) --- AKPlan/templates/AKPlan/encode_events.html | 17 +++++++++++++++++ AKPlan/templates/AKPlan/encode_rooms.html | 15 +++++++++++++++ AKPlan/templates/AKPlan/plan_index.html | 22 ++-------------------- AKPlan/templates/AKPlan/plan_wall.html | 13 +------------ AKPlan/views.py | 6 ++++++ AKPlanning/settings.py | 2 ++ 6 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 AKPlan/templates/AKPlan/encode_events.html create mode 100644 AKPlan/templates/AKPlan/encode_rooms.html diff --git a/AKPlan/templates/AKPlan/encode_events.html b/AKPlan/templates/AKPlan/encode_events.html new file mode 100644 index 00000000..2cb97b19 --- /dev/null +++ b/AKPlan/templates/AKPlan/encode_events.html @@ -0,0 +1,17 @@ +{% load tz %} + +[ + {% for slot in slots %} + {% if slot.start %} + { + 'title': '{{ slot.ak.name }}', + 'start': '{{ slot.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}', + 'end': '{{ slot.end | timezone:event.timezone | date:"Y-m-d H:i:s" }}', + 'resourceId': '{{ slot.room.title }}', + 'backgroundColor': '{{ slot.ak.category.color }}', + 'borderColor': '{{ slot.ak.track.color }}', + 'url': '{% url 'submit:ak_detail' event_slug=event.slug pk=slot.ak.pk %}' + }, + {% endif %} + {% endfor %} +] diff --git a/AKPlan/templates/AKPlan/encode_rooms.html b/AKPlan/templates/AKPlan/encode_rooms.html new file mode 100644 index 00000000..55138df0 --- /dev/null +++ b/AKPlan/templates/AKPlan/encode_rooms.html @@ -0,0 +1,15 @@ +[ + {% for room in rooms %} + { + 'id': '{{ room.title }}', + 'title': '{{ room.title }}', + 'parentId': '{{ room.building }}', + }, + {% endfor %} + {% for building in buildings %} + { + 'id': '{{ building }}', + 'title': '{{ building }}', + }, + {% endfor %} +] diff --git a/AKPlan/templates/AKPlan/plan_index.html b/AKPlan/templates/AKPlan/plan_index.html index 520c678e..032d8eda 100644 --- a/AKPlan/templates/AKPlan/plan_index.html +++ b/AKPlan/templates/AKPlan/plan_index.html @@ -57,26 +57,8 @@ eventColor: '#127ba3', resourceAreaWidth: '15%', resourceLabelText: '{% trans "Room" %}', - resources: [ - {% for room in rooms %} - { - 'id': '{{ room.title }}', - 'title': '{{ room.title }}' - }, - {% endfor %} - ], - events: [ - {% for slot in akslots %} - {% if slot.room and slot.start %} - { - 'title': '{{ slot.ak.name }}', - 'start': '{{ slot.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}', - 'end': '{{ slot.end | timezone:event.timezone | date:"Y-m-d H:i:s" }}', - 'resourceId': '{{ slot.room.title }}', - }, - {% endif %} - {% endfor %} - ], + resources: {% include "AKPlan/encode_rooms.html" %}, + events: {% with akslots as slots %}{% include "AKPlan/encode_events.html" %}{% endwith %}, schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source', }); diff --git a/AKPlan/templates/AKPlan/plan_wall.html b/AKPlan/templates/AKPlan/plan_wall.html index ca089605..7507e88f 100644 --- a/AKPlan/templates/AKPlan/plan_wall.html +++ b/AKPlan/templates/AKPlan/plan_wall.html @@ -70,18 +70,7 @@ }, {% endfor %} ], - events: [ - {% for slot in akslots %} - {% if slot.room and slot.start %} - { - 'title': '{{ slot.ak.name }}', - 'start': '{{ slot.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}', - 'end': '{{ slot.end | timezone:event.timezone | date:"Y-m-d H:i:s" }}', - 'resourceId': '{{ slot.room.title }}', - }, - {% endif %} - {% endfor %} - ], + events: {% with akslots as slots %}{% include "AKPlan/encode_events.html" %}{% endwith %}, schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source', }); diff --git a/AKPlan/views.py b/AKPlan/views.py index b1b598cc..e1b61915 100644 --- a/AKPlan/views.py +++ b/AKPlan/views.py @@ -28,12 +28,16 @@ class PlanIndexView(FilterByEventSlugMixin, ListView): context["akslots_now"] = [] context["akslots_next"] = [] rooms = set() + buildings = set() # Get list of current and next slots for akslot in context["akslots"]: # Construct a list of all rooms used by these slots on the fly if akslot.room is not None: rooms.add(akslot.room) + # Store buildings for hierarchical view + if akslot.room.building != '': + buildings.add(akslot.room.building) # Recent AKs: Started but not ended yet if akslot.start <= current_timestamp <= akslot.end: @@ -45,6 +49,8 @@ class PlanIndexView(FilterByEventSlugMixin, ListView): # Sort list of rooms by title context["rooms"] = sorted(rooms, key=lambda x: x.title) + if settings.PLAN_SHOW_HIERARCHY: + context["buildings"] = sorted(buildings) return context diff --git a/AKPlanning/settings.py b/AKPlanning/settings.py index 57cb81e5..fc67a542 100644 --- a/AKPlanning/settings.py +++ b/AKPlanning/settings.py @@ -162,5 +162,7 @@ PLAN_MAX_NEXT_AKS = 10 # Specify range of plan for screen/projector view PLAN_WALL_HOURS_RETROSPECT = 3 PLAN_WALL_HOURS_FUTURE = 18 +# Should the plan use a hierarchy of buildings and rooms? +PLAN_SHOW_HIERARCHY = True include(optional("settings/*.py")) -- GitLab