From 3926f0ea0e11e3537bb1766f9d286f76080855c7 Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Mon, 15 Jun 2020 15:33:59 +0200 Subject: [PATCH] Add status icon for every lesson --- .../alsijil/templates/alsijil/lesson.html | 4 ++++ .../alsijil/partials/lesson_status_icon.html | 24 +++++++++++++++++++ .../alsijil/templates/alsijil/week_view.html | 23 ++++-------------- 3 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 aleksis/apps/alsijil/templates/alsijil/partials/lesson_status_icon.html diff --git a/aleksis/apps/alsijil/templates/alsijil/lesson.html b/aleksis/apps/alsijil/templates/alsijil/lesson.html index 7614a51c1..16b2579c7 100644 --- a/aleksis/apps/alsijil/templates/alsijil/lesson.html +++ b/aleksis/apps/alsijil/templates/alsijil/lesson.html @@ -21,6 +21,10 @@ {% for teacher in lesson_period.get_teachers.all %} {{ teacher.short_name }} {% endfor %} + + <span class="right"> + {% include "alsijil/partials/lesson_status_icon.html" with period=lesson_period css_class="medium" %} + </span> {% endblock %} {% block content %} diff --git a/aleksis/apps/alsijil/templates/alsijil/partials/lesson_status_icon.html b/aleksis/apps/alsijil/templates/alsijil/partials/lesson_status_icon.html new file mode 100644 index 000000000..08746b5c9 --- /dev/null +++ b/aleksis/apps/alsijil/templates/alsijil/partials/lesson_status_icon.html @@ -0,0 +1,24 @@ +{% load i18n week_helpers %} + +{% now_datetime as now_dt %} + +{% if period.has_documentation %} + <i class="material-icons green-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Data complete" %}" title="{% trans "Data complete" %}">check_circle</i> +{% else %} + {% period_to_time_start week period.period as time_start %} + {% period_to_time_end week period.period as time_end %} + + {% if now_dt > time_end %} + <i class="material-icons red-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Missing data" %}" title="{% trans "Missing data" %}">history</i> + {% elif now_dt > time_start and now_dt < time_end %} + <i class="material-icons orange-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Pending" %}" title="{% trans "Pending" %}">more_horiz</i> + {% else %} + {% if period.get_substitution %} + {% if period.get_substitution.cancelled %} + <i class="material-icons red-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Lesson cancelled" %}" title="{% trans "Lesson cancelled" %}">cancel</i> + {% else %} + <i class="material-icons orange-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Substitution" %}" title="{% trans "Substitution" %}">update</i> + {% endif %} + {% endif %} + {% endif %} +{% endif %} diff --git a/aleksis/apps/alsijil/templates/alsijil/week_view.html b/aleksis/apps/alsijil/templates/alsijil/week_view.html index 0e160ef17..e709d4871 100644 --- a/aleksis/apps/alsijil/templates/alsijil/week_view.html +++ b/aleksis/apps/alsijil/templates/alsijil/week_view.html @@ -45,6 +45,7 @@ <table class="striped responsive-table datatable"> <thead> <tr> + <th></th> <th>{% blocktrans %}Period{% endblocktrans %}</th> <th>{% blocktrans %}Subject{% endblocktrans %}</th> <th>{% blocktrans %}Teachers{% endblocktrans %}</th> @@ -52,24 +53,10 @@ </thead> <tbody> {% for period in periods %} - <tr class=" - {% if period.has_documentation %} - success - {% else %} - {% weekday_to_date week period.period.weekday as current_date %} - {% today as today %} - {% if current_date < today %} - error - {% else %} - {% if period.get_substitution %} - warning - {% if period.get_substitution.cancelled %} - alsijil-lesson-cancelled - {% endif %} - {% endif %} - {% endif %} - {% endif %} - "> + <tr> + <td class="center-align"> + {% include "alsijil/partials/lesson_status_icon.html" with period=period %} + </td> <td>{{ period.period.period }}</td> <td> <a href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}"> -- GitLab