From f84dfd5bcc4d085a17dd79a953f5536afd7a38fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?= <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de> Date: Tue, 12 May 2020 02:24:19 +0200 Subject: [PATCH] Add per-event dashboards --- .../templates/AKDashboard/dashboard.html | 65 +----------------- .../AKDashboard/dashboard_event.html | 23 +++++++ .../templates/AKDashboard/dashboard_row.html | 67 +++++++++++++++++++ AKDashboard/urls.py | 1 + AKDashboard/views.py | 7 +- 5 files changed, 98 insertions(+), 65 deletions(-) create mode 100644 AKDashboard/templates/AKDashboard/dashboard_event.html create mode 100644 AKDashboard/templates/AKDashboard/dashboard_row.html diff --git a/AKDashboard/templates/AKDashboard/dashboard.html b/AKDashboard/templates/AKDashboard/dashboard.html index 2f3a7b6a..04502d66 100644 --- a/AKDashboard/templates/AKDashboard/dashboard.html +++ b/AKDashboard/templates/AKDashboard/dashboard.html @@ -3,7 +3,6 @@ {% load fontawesome_5 %} {% load i18n %} {% load static %} -{% load tags_AKModel %} {% block imports %} @@ -19,69 +18,7 @@ {% block content %} {% for event in events %} - <div class="dashboard-row"> - <h2> {{ event.name }} </h2> - <div class="row"> - {% if 'AKSubmission'|check_app_installed %} - <a class="dashboard-box btn btn-primary" - href="{% url 'submit:ak_list' event_slug=event.slug %}"> - <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> - <span class="fa fa-list-ul"></span> - <span class='text'>{% trans 'AK List' %}</span> - </div> - </a> - {% endif %} - {% if 'AKPlan'|check_app_installed %} - {% if event.active %} - <a class="dashboard-box btn btn-primary" - href="{% url 'plan:plan_overview' event_slug=event.slug %}"> - <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> - <span class="fa fa-clock"></span> - <span class='text'>{% trans 'Current AKs' %}</span> - </div> - </a> - <a class="dashboard-box btn btn-primary" - href="{% url 'plan:plan_wall' event_slug=event.slug %}"> - <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> - <span class="fa fa-calendar"></span> - <span class='text'>{% trans 'AK Wall' %}</span> - </div> - </a> - {% else %} - <a class="dashboard-box btn btn-primary" - href="{% url 'plan:plan_overview' event_slug=event.slug %}"> - <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> - <span class="fa fa-calendar-alt"></span> - <span class='text'>{% trans 'Schedule' %}</span> - </div> - </a> - {% endif %} - {% endif %} - {% if 'AKSubmission'|check_app_installed %} - <a class="dashboard-box btn btn-primary" - href="{% url 'submit:submission_overview' event_slug=event.slug %}"> - <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> - <span class="fa fa-pencil-alt"></span> - <span class='text'>{% trans 'AK Submission' %}</span> - </div> - </a> - {% endif %} - {% for button in event.dashboardbutton_set.all %} - <a class="dashboard-box btn btn-{{ button.get_color_display }}" - href="{{ button.url }}"> - <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> - {% if button.icon %}<span class="fa">{{ button.icon.as_html }}</span>{% endif %} - <span class='text'>{{ button.text }}</span> - </div> - </a> - {% endfor %} - </div> - {% if event.contact_email %} - <p> - <a href="mailto:{{ event.contact_email }}">{% fa5_icon "envelope" "fas" %} {% trans "Write to organizers of this event for questions and comments" %}</a> - </p> - {% endif %} - </div> + {% include "AKDashboard/dashboard_row.html" %} {% empty %} <div class="jumbotron"> <h2 class="display-4"> diff --git a/AKDashboard/templates/AKDashboard/dashboard_event.html b/AKDashboard/templates/AKDashboard/dashboard_event.html new file mode 100644 index 00000000..d91c688b --- /dev/null +++ b/AKDashboard/templates/AKDashboard/dashboard_event.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} + +{% load fontawesome_5 %} +{% load i18n %} +{% load static %} +{% load tags_AKModel %} + +{% block imports %} + + {{ block.super }} + + <link rel="stylesheet" href="{% static 'AKDashboard/style.css' %}"> + +{% endblock %} + +{% block breadcrumbs %} + <li class="breadcrumb-item"><a href="{% url 'dashboard:dashboard' %}">AKPlanning</a></li> + <li class="breadcrumb-item active">{{ event.slug }}</li> +{% endblock %} + +{% block content %} + {% include "AKDashboard/dashboard_row.html" %} +{% endblock %} diff --git a/AKDashboard/templates/AKDashboard/dashboard_row.html b/AKDashboard/templates/AKDashboard/dashboard_row.html new file mode 100644 index 00000000..36b32af5 --- /dev/null +++ b/AKDashboard/templates/AKDashboard/dashboard_row.html @@ -0,0 +1,67 @@ +{% load i18n %} +{% load tags_AKModel %} +{% load fontawesome_5 %} + +<div class="dashboard-row"> + <h2> {{ event.name }} </h2> + <div class="row"> + {% if 'AKSubmission'|check_app_installed %} + <a class="dashboard-box btn btn-primary" + href="{% url 'submit:ak_list' event_slug=event.slug %}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + <span class="fa fa-list-ul"></span> + <span class='text'>{% trans 'AK List' %}</span> + </div> + </a> + {% endif %} + {% if 'AKPlan'|check_app_installed %} + {% if event.active %} + <a class="dashboard-box btn btn-primary" + href="{% url 'plan:plan_overview' event_slug=event.slug %}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + <span class="fa fa-clock"></span> + <span class='text'>{% trans 'Current AKs' %}</span> + </div> + </a> + <a class="dashboard-box btn btn-primary" + href="{% url 'plan:plan_wall' event_slug=event.slug %}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + <span class="fa fa-calendar"></span> + <span class='text'>{% trans 'AK Wall' %}</span> + </div> + </a> + {% else %} + <a class="dashboard-box btn btn-primary" + href="{% url 'plan:plan_overview' event_slug=event.slug %}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + <span class="fa fa-calendar-alt"></span> + <span class='text'>{% trans 'Schedule' %}</span> + </div> + </a> + {% endif %} + {% endif %} + {% if 'AKSubmission'|check_app_installed %} + <a class="dashboard-box btn btn-primary" + href="{% url 'submit:submission_overview' event_slug=event.slug %}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + <span class="fa fa-pencil-alt"></span> + <span class='text'>{% trans 'AK Submission' %}</span> + </div> + </a> + {% endif %} + {% for button in event.dashboardbutton_set.all %} + <a class="dashboard-box btn btn-{{ button.get_color_display }}" + href="{{ button.url }}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + {% if button.icon %}<span class="fa">{{ button.icon.as_html }}</span>{% endif %} + <span class='text'>{{ button.text }}</span> + </div> + </a> + {% endfor %} + </div> + {% if event.contact_email %} + <p> + <a href="mailto:{{ event.contact_email }}">{% fa5_icon "envelope" "fas" %} {% trans "Write to organizers of this event for questions and comments" %}</a> + </p> + {% endif %} +</div> diff --git a/AKDashboard/urls.py b/AKDashboard/urls.py index 24497d30..9cc1728c 100644 --- a/AKDashboard/urls.py +++ b/AKDashboard/urls.py @@ -6,4 +6,5 @@ app_name = "dashboard" urlpatterns = [ path('', views.DashboardView.as_view(), name="dashboard"), + path('<slug:slug>/', views.DashboardEventView.as_view(), name='dashboard_event'), ] diff --git a/AKDashboard/views.py b/AKDashboard/views.py index 6d870680..1a0bed6d 100644 --- a/AKDashboard/views.py +++ b/AKDashboard/views.py @@ -1,6 +1,6 @@ from django.utils.decorators import method_decorator from django.views.decorators.csrf import ensure_csrf_cookie -from django.views.generic import TemplateView +from django.views.generic import TemplateView, DetailView from AKModel.models import Event @@ -16,3 +16,8 @@ class DashboardView(TemplateView): context = super().get_context_data(**kwargs) context['events'] = Event.objects.all() return context + +class DashboardEventView(DetailView): + template_name = 'AKDashboard/dashboard_event.html' + context_object_name = 'event' + model = Event -- GitLab