From 4590d41e2b5286cd2eecda670f75c731d72cc047 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 01:57:11 +0100 Subject: [PATCH] Introduce detail views for room and track plans --- AKPlan/locale/de_DE/LC_MESSAGES/django.po | 39 +++++++++++------ AKPlan/templates/AKPlan/plan_detail.html | 53 +++++++++++++++++++++++ AKPlan/templates/AKPlan/plan_index.html | 22 +++++++++- AKPlan/templates/AKPlan/plan_room.html | 53 +++++++++++++++++++++++ AKPlan/templates/AKPlan/plan_track.html | 53 +++++++++++++++++++++++ AKPlan/urls.py | 2 + AKPlan/views.py | 25 ++++++++++- 7 files changed, 231 insertions(+), 16 deletions(-) create mode 100644 AKPlan/templates/AKPlan/plan_detail.html create mode 100644 AKPlan/templates/AKPlan/plan_room.html create mode 100644 AKPlan/templates/AKPlan/plan_track.html diff --git a/AKPlan/locale/de_DE/LC_MESSAGES/django.po b/AKPlan/locale/de_DE/LC_MESSAGES/django.po index 90548ac6..234e7500 100644 --- a/AKPlan/locale/de_DE/LC_MESSAGES/django.po +++ b/AKPlan/locale/de_DE/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-03-02 22:35+0000\n" +"POT-Creation-Date: 2020-03-04 00:53+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -17,37 +17,50 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: templates/AKPlan/plan_index.html:47 +#: templates/AKPlan/plan_base.html:24 +msgid "Write to organizers of this event for questions and comments" +msgstr "Fragen oder Kommentare? Schreib den Orgas dieses Events eine Mail" + +#: templates/AKPlan/plan_breadcrumbs.html:13 +msgid "AK Plan" +msgstr "AK-Plan" + +#: templates/AKPlan/plan_index.html:40 msgid "Day" msgstr "Tag" -#: templates/AKPlan/plan_index.html:57 +#: templates/AKPlan/plan_index.html:50 msgid "Event" msgstr "Veranstaltung" -#: templates/AKPlan/plan_index.html:66 templates/AKPlan/plan_wall.html:64 +#: templates/AKPlan/plan_index.html:59 templates/AKPlan/plan_room.html:8 +#: templates/AKPlan/plan_room.html:44 templates/AKPlan/plan_wall.html:64 msgid "Room" msgstr "Raum" -#: templates/AKPlan/plan_index.html:106 -msgid "AK Plan" -msgstr "AK-Plan" +#: templates/AKPlan/plan_index.html:80 templates/AKPlan/plan_room.html:34 +msgid "Rooms" +msgstr "Räume" + +#: templates/AKPlan/plan_index.html:88 templates/AKPlan/plan_track.html:34 +msgid "Tracks" +msgstr "Tracks" -#: templates/AKPlan/plan_index.html:112 +#: templates/AKPlan/plan_index.html:96 msgid "AK Wall" msgstr "AK-Wall" -#: templates/AKPlan/plan_index.html:120 templates/AKPlan/plan_wall.html:99 +#: templates/AKPlan/plan_index.html:106 templates/AKPlan/plan_wall.html:88 msgid "Current AKs" msgstr "Aktuelle AKs" -#: templates/AKPlan/plan_index.html:127 templates/AKPlan/plan_wall.html:104 +#: templates/AKPlan/plan_index.html:113 templates/AKPlan/plan_wall.html:93 msgid "Next AKs" msgstr "Nächste AKs" -#: templates/AKPlan/plan_index.html:144 -msgid "Write to organizers of this event for questions and comments" -msgstr "Fragen oder Kommentare? Schreib den Orgas dieses Events eine Mail" +#: templates/AKPlan/plan_track.html:8 templates/AKPlan/plan_track.html:44 +msgid "Track" +msgstr "Track" #: templates/AKPlan/slots_table.html:12 msgid "No AKs" diff --git a/AKPlan/templates/AKPlan/plan_detail.html b/AKPlan/templates/AKPlan/plan_detail.html new file mode 100644 index 00000000..c1ce04ef --- /dev/null +++ b/AKPlan/templates/AKPlan/plan_detail.html @@ -0,0 +1,53 @@ +{% extends "AKPlan/plan_base.html" %} + +{% load fontawesome_5 %} +{% load i18n %} +{% load static %} +{% load tz %} + + +{% block fullcalendar %} + {% get_current_language as LANGUAGE_CODE %} + + <link href='{% static 'AKPlan/fullcalendar/daygrid/main.min.css' %}' rel='stylesheet' /> + <link href='{% static 'AKPlan/fullcalendar/timegrid/main.min.css' %}' rel='stylesheet' /> + + <script src='{% static 'AKPlan/fullcalendar/daygrid/main.min.js' %}'></script> + <script src='{% static 'AKPlan/fullcalendar/timegrid/main.min.js' %}'></script> + + <script> + document.addEventListener('DOMContentLoaded', function() { + var calendarEl = document.getElementById('planCalendar'); + + var calendar = new FullCalendar.Calendar(calendarEl, { + plugins: [ 'timeGrid', 'bootstrap' ], + // Adapt to timezone of the connected event + timeZone: '{{ event.timezone }}', + defaultView: 'timeGrid', + // Adapt to user selected locale + locale: '{{ LANGUAGE_CODE }}', + // No header, not buttons + header: { + left: '', + center: '', + right: '' + }, + aspectRatio: 2, + themeSystem: 'bootstrap', + // Only show calendar view for the dates of the connected event + visibleRange: { + start: '{{ event.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}', + end: '{{ event.end | timezone:event.timezone | date:"Y-m-d H:i:s"}}', + }, + allDaySlot: false, + nowIndicator: true, + eventTextColor: '#fff', + eventColor: '#127ba3', + // Create entries for all scheduled slots + events: {% block encode %}{% endblock %} + }); + + calendar.render(); + }); + </script> +{% endblock %} diff --git a/AKPlan/templates/AKPlan/plan_index.html b/AKPlan/templates/AKPlan/plan_index.html index 032d8eda..75b0cf86 100644 --- a/AKPlan/templates/AKPlan/plan_index.html +++ b/AKPlan/templates/AKPlan/plan_index.html @@ -75,7 +75,27 @@ {% block content %} <div class="float-right"> - <a href="{% url 'plan:plan_wall' event_slug=event.slug %}" class="btn btn-success">{% fa5_icon 'desktop' 'fas' %} {% trans "AK Wall" %}</a> + <ul class="nav nav-pills"> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{% trans "Rooms" %}</a> + <div class="dropdown-menu" style=""> + {% for r in event.room_set.all %} + <a class="dropdown-item" href="{% url "plan:plan_room" event_slug=event.slug pk=r.pk %}">{{ r }}</a> + {% endfor %} + </div> + </li> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{% trans "Tracks" %}</a> + <div class="dropdown-menu"> + {% for t in event.aktrack_set.all %} + <a class="dropdown-item" href="{% url "plan:plan_track" event_slug=event.slug pk=t.pk %}">{{ t }}</a> + {% endfor %} + </div> + </li> + <li class="nav-item"> + <a class="nav-link active" href="{% url 'plan:plan_wall' event_slug=event.slug %}">{% fa5_icon 'desktop' 'fas' %} {% trans "AK Wall" %}</a> + </li> + </ul> </div> <h1>Plan: {{ event }}</h1> diff --git a/AKPlan/templates/AKPlan/plan_room.html b/AKPlan/templates/AKPlan/plan_room.html new file mode 100644 index 00000000..6f956563 --- /dev/null +++ b/AKPlan/templates/AKPlan/plan_room.html @@ -0,0 +1,53 @@ +{% extends "AKPlan/plan_detail.html" %} + +{% load tz %} +{% load i18n %} + +{% block breadcrumbs %} + {% include "AKPlan/plan_breadcrumbs.html" %} + <li class="breadcrumb-item">{% trans "Room" %}</li> + <li class="breadcrumb-item">{{ room.title }}</li> +{% endblock %} + + +{% block encode %} +[ + {% for slot in room.akslot_set.all %} + {% if slot.start %} + {'title': '{{ slot.ak }}', + '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" }}', + 'url': '{% url 'submit:ak_detail' event_slug=event.slug pk=slot.ak.pk %}', + 'borderColor': '{{ slot.ak.track.color }}', + 'color': '{{ slot.ak.category.color }}', + }, + {% endif %} + {% endfor %} +] +{% endblock %} + + +{% block content %} + <div class="float-right"> + <ul class="nav nav-pills"> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{% trans "Rooms" %}</a> + <div class="dropdown-menu" style=""> + {% for r in event.room_set.all %} + <a class="dropdown-item" href="{% url "plan:plan_room" event_slug=event.slug pk=r.pk %}">{{ r }}</a> + {% endfor %} + </div> + </li> + </ul> + </div> + + <h1>Plan: {{ event }} -- {% trans "Room" %}: {{ room }}</h1> + + {% timezone event.timezone %} + <div class="row" style="margin-top:30px;clear:both;"> + <div class="col-md-12"> + <div id="planCalendar"></div> + </div> + </div> + {% endtimezone %} +{% endblock %} diff --git a/AKPlan/templates/AKPlan/plan_track.html b/AKPlan/templates/AKPlan/plan_track.html new file mode 100644 index 00000000..da452573 --- /dev/null +++ b/AKPlan/templates/AKPlan/plan_track.html @@ -0,0 +1,53 @@ +{% extends "AKPlan/plan_detail.html" %} + +{% load tz %} +{% load i18n %} + +{% block breadcrumbs %} + {% include "AKPlan/plan_breadcrumbs.html" %} + <li class="breadcrumb-item">{% trans "Track" %}</li> + <li class="breadcrumb-item">{{ track }}</li> +{% endblock %} + + +{% block encode %} +[ + {% for slot in slots %} + {% if slot.start %} + {'title': '{{ slot.ak }} @ {{ slot.room }}', + '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" }}', + 'url': '{% url 'submit:ak_detail' event_slug=event.slug pk=slot.ak.pk %}', + 'color': '{{ track.color }}', + 'borderColor': '{{ slot.ak.category.color }}', + }, + {% endif %} + {% endfor %} +] +{% endblock %} + + +{% block content %} + <div class="float-right"> + <ul class="nav nav-pills"> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{% trans "Tracks" %}</a> + <div class="dropdown-menu"> + {% for t in event.aktrack_set.all %} + <a class="dropdown-item" href="{% url "plan:plan_track" event_slug=event.slug pk=t.pk %}">{{ t }}</a> + {% endfor %} + </div> + </li> + </ul> + </div> + + <h1>Plan: {{ event }} -- {% trans "Track" %}: {{ track }}</h1> + + {% timezone event.timezone %} + <div class="row" style="margin-top:30px;clear: both;"> + <div class="col-md-12"> + <div id="planCalendar"></div> + </div> + </div> + {% endtimezone %} +{% endblock %} diff --git a/AKPlan/urls.py b/AKPlan/urls.py index 2206cd0e..d45f64c7 100644 --- a/AKPlan/urls.py +++ b/AKPlan/urls.py @@ -9,6 +9,8 @@ urlpatterns = [ include([ path('', views.PlanIndexView.as_view(), name='plan_overview'), path('wall/', views.PlanScreenView.as_view(), name='plan_wall'), + path('room/<int:pk>/', views.PlanRoomView.as_view(), name='plan_room'), + path('track/<int:pk>/', views.PlanTrackView.as_view(), name='plan_track'), ]) ), ] diff --git a/AKPlan/views.py b/AKPlan/views.py index e1b61915..f96a9726 100644 --- a/AKPlan/views.py +++ b/AKPlan/views.py @@ -2,9 +2,9 @@ from datetime import timedelta from django.conf import settings from django.utils.datetime_safe import datetime -from django.views.generic import ListView +from django.views.generic import ListView, DetailView -from AKModel.models import AKSlot +from AKModel.models import AKSlot, Room, AKTrack from AKModel.views import FilterByEventSlugMixin @@ -72,3 +72,24 @@ class PlanScreenView(PlanIndexView): context["start"] = self.start context["end"] = self.end return context + + +class PlanRoomView(FilterByEventSlugMixin, DetailView): + template_name = "AKPlan/plan_room.html" + model = Room + context_object_name = "room" + + +class PlanTrackView(FilterByEventSlugMixin, DetailView): + template_name = "AKPlan/plan_track.html" + model = AKTrack + context_object_name = "track" + + def get_context_data(self, *, object_list=None, **kwargs): + context = super().get_context_data(object_list=object_list, **kwargs) + + context["slots"] = [] + for ak in context["track"].ak_set.all(): + context["slots"].extend(ak.akslot_set.all()) + + return context -- GitLab