From 329a6d46eb117c132b7d5df1c76dfc1f5fc4ba3a Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Fri, 10 Jan 2020 13:42:46 +0100 Subject: [PATCH] Refactor var names and reformat in lesson.html and plan.html --- .../chronos/templates/chronos/lesson.html | 263 +++++++++--------- .../apps/chronos/templates/chronos/plan.html | 4 +- 2 files changed, 134 insertions(+), 133 deletions(-) diff --git a/aleksis/apps/chronos/templates/chronos/lesson.html b/aleksis/apps/chronos/templates/chronos/lesson.html index 5b2cca1c..2b165fc9 100644 --- a/aleksis/apps/chronos/templates/chronos/lesson.html +++ b/aleksis/apps/chronos/templates/chronos/lesson.html @@ -1,141 +1,142 @@ <div class="card lesson-card"> - <div class="card-content"> - - {# Every element of the lesson #} - {% for element_container in col.elements %} - <div style=" - - {# Display background color only if no badge exists and it is not the old room and there are no holidays #} - {% if not element_container.substitution.table.badge %} - {% if not element_container.is_old or type != 1 %} - {% if not element_container.is_hol %} - background-color: {{ element_container.element.subject.hex_color }}; - {% endif %} - {% endif %} - {% endif %}" - - {# Add CSS class for sub when it's a sub #} - class="{% if element_container.substitution %}{% if element_container.substitution.table.is_event %}lesson-with-event{% else %}lesson-with-sub{% endif %}{% endif %}"> - <p> - {% if element_container.is_hol %} - - {# <p><strong>{ element_container.element.holiday_reason }}</strong></p>span class="badge new blue darken-2">Schulfrei</span>#} - - {% elif element_container.substitution %} - {# SUBSTITUTION #} - {% if type == 1 and element_container.is_old %} - {# When it's the old room, let it empty #} - - {% elif element_container.substitution.table.badge %} - {# When a badge (cancellation, etc.) exists, then display it with the teacher#} - - {# Class or room > Display teacher #} - {% if type == 2 or type == 1 %} - {% if element_container.element.teacher %} - <span data-position="bottom" class="tooltipped" - data-tooltip="{{ element_container.element.teacher }}"> + <div class="card-content"> + + {# Every element of the lesson #} + {% for lesson in lessons %} + <div style=" + + {# Display background color only if no badge exists and it is not the old room and there are no holidays #} + {% if not lesson.substitution.table.badge %} + {% if not lesson.is_old or type != 1 %} + {% if not lesson.is_hol %} + background-color: {{ lesson.element.subject.hex_color }}; + {% endif %} + {% endif %} + {% endif %}" + + {# Add CSS class for sub when it's a sub #} + class=" + {% if lesson.substitution %}{% if lesson.substitution.table.is_event %}lesson-with-event{% else %}lesson-with-sub{% endif %}{% endif %}"> + <p> + {% if lesson.is_hol %} + + {# <p><strong>{ element_container.element.holiday_reason }}</strong></p>span class="badge new blue darken-2">Schulfrei</span>#} + + {% elif lesson.substitution %} + {# SUBSTITUTION #} + {% if type == 1 and lesson.is_old %} + {# When it's the old room, let it empty #} + + {% elif lesson.substitution.table.badge %} + {# When a badge (cancellation, etc.) exists, then display it with the teacher#} + + {# Class or room > Display teacher #} + {% if type == 2 or type == 1 %} + {% if lesson.element.teacher %} + <span data-position="bottom" class="tooltipped" + data-tooltip="{{ lesson.element.teacher }}"> <a - href="{% url "timetable_smart_plan" "teacher" element_container.element.teacher.id %}">{{ element_container.element.teacher.shortcode }}</a> + href="{% url "timetable_smart_plan" "teacher" lesson.element.teacher.id %}">{{ lesson.element.teacher.shortcode }}</a> </span> - <br> - {% endif %} - {% endif %} - - {# Badge #} - <span class="badge new green darken-2">{{ element_container.substitution.table.badge }}</span> - - - - {% else %} - {# Display sub #} - - {% with sub=element_container.substitution.table %} - {# Teacher or room > display classes #} - {% if type == 0 or type == 1 %} - {{ element_container.substitution.table.classes }} - {% endif %} - - {# Display teacher with tooltip #} - {% include "timetable/subs/teacher.html" %} - - {# Display subject #} - {% include "timetable/subs/subject.html" %} - - {# Teacher or class > display room #} - {% if type == 0 or type == 2 %} - {% include "timetable/subs/room.html" %} - {% endif %} - {% endwith %} - {% endif %} - - {# When it isn't a room or the old plan, then display the extra text (e. g. work orders) AND NOT A EVENT#} - {% if not element_container.substitution.table.is_event %} - {% if not type == 1 or not element_container.is_old %} - <br> - <small> - <em>{{ element_container.substitution.table.text|default:"" }}</em> - </small> - {% endif %} - {% endif %} - {# Display the extra text for events #} - {% if element_container.substitution.table.is_event %} - {% if type == 0 and element_container.substitution.table.classes == "" and element_container.substitution.table.rooms|length == 0 and element_container.substitutions.table.teachers|length == 0 %} - <em>{{ element_container.substitution.table.text|default:"" }}</em> - {% elif type == 2 and element_container.substitution.table.teachers|length == 0 and element_container.substitution.table.rooms|length == 0 %} - <em>{{ element_container.substitution.table.text|default:"" }}</em> - {% elif type == 1 and element_container.substitution.table.teachers|length == 0 and element_container.substitution.table.classes == "" %} - <em>{{ element_container.substitution.table.text|default:"" }}</em> - {% else %} - <br> - <small> - <em>{{ element_container.substitution.table.text|default:"" }}</em> - </small> - {% endif %} - {% endif %} - - {% else %} - {# Normal plan #} - - {# Teacher or room > Display classes #} - {% if type == 0 or type == 1 %} - {# {{ element_container.element.classes }}#} - {% if element_container.element.classes %} - <a href="{% url "timetable_smart_plan" "class" element_container.element.classes.0.id %}"> - {{ element_container.classes_formatted }} - </a> - {% endif %} - {% endif %} - - {# Class or room > Display teacher #} - {% if type == 2 or type == 1 %} - {% if element_container.element.teacher %} - <span data-position="bottom" class="tooltipped" - data-tooltip="{{ element_container.element.teacher }}"> - <a href="{% url "timetable_smart_plan" "teacher" element_container.element.teacher.id %}"> - {{ element_container.element.teacher.shortcode }} + <br> + {% endif %} + {% endif %} + + {# Badge #} + <span class="badge new green darken-2">{{ lesson.substitution.table.badge }}</span> + + + + {% else %} + {# Display sub #} + + {% with sub=lesson.substitution.table %} + {# Teacher or room > display classes #} + {% if type == 0 or type == 1 %} + {{ lesson.substitution.table.classes }} + {% endif %} + + {# Display teacher with tooltip #} + {% include "timetable/subs/teacher.html" %} + + {# Display subject #} + {% include "timetable/subs/subject.html" %} + + {# Teacher or class > display room #} + {% if type == 0 or type == 2 %} + {% include "timetable/subs/room.html" %} + {% endif %} + {% endwith %} + {% endif %} + + {# When it isn't a room or the old plan, then display the extra text (e. g. work orders) AND NOT A EVENT#} + {% if not lesson.substitution.table.is_event %} + {% if not type == 1 or not lesson.is_old %} + <br> + <small> + <em>{{ lesson.substitution.table.text|default:"" }}</em> + </small> + {% endif %} + {% endif %} + {# Display the extra text for events #} + {% if lesson.substitution.table.is_event %} + {% if type == 0 and lesson.substitution.table.classes == "" and lesson.substitution.table.rooms|length == 0 and lesson.substitutions.table.teachers|length == 0 %} + <em>{{ lesson.substitution.table.text|default:"" }}</em> + {% elif type == 2 and lesson.substitution.table.teachers|length == 0 and lesson.substitution.table.rooms|length == 0 %} + <em>{{ lesson.substitution.table.text|default:"" }}</em> + {% elif type == 1 and lesson.substitution.table.teachers|length == 0 and lesson.substitution.table.classes == "" %} + <em>{{ lesson.substitution.table.text|default:"" }}</em> + {% else %} + <br> + <small> + <em>{{ lesson.substitution.table.text|default:"" }}</em> + </small> + {% endif %} + {% endif %} + + {% else %} + {# Normal plan #} + + {# Teacher or room > Display classes #} + {% if type == 0 or type == 1 %} + {# {{ element_container.element.classes }}#} + {% if lesson.element.classes %} + <a href="{% url "timetable_smart_plan" "class" lesson.element.classes.0.id %}"> + {{ lesson.classes_formatted }} + </a> + {% endif %} + {% endif %} + + {# Class or room > Display teacher #} + {% if type == 2 or type == 1 %} + {% if lesson.element.teacher %} + <span data-position="bottom" class="tooltipped" + data-tooltip="{{ lesson.element.teacher }}"> + <a href="{% url "timetable_smart_plan" "teacher" lesson.element.teacher.id %}"> + {{ lesson.element.teacher.shortcode }} </a> </span> - {% endif %} - {% endif %} - - {# Display subject #} - <strong>{{ element_container.element.subject.shortcode }}</strong> - - {# Teacher or class > Display room #} - {% if type == 0 or type == 2 %} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ element_container.room.name }}"> - {% if element_container.room %} - <a href="{% url "timetable_smart_plan" "room" element_container.room.id %}"> - {{ element_container.room.shortcode }} + {% endif %} + {% endif %} + + {# Display subject #} + <strong>{{ lesson.element.subject.shortcode }}</strong> + + {# Teacher or class > Display room #} + {% if type == 0 or type == 2 %} + <span class="tooltipped" data-position="bottom" + data-tooltip="{{ lesson.room.name }}"> + {% if lesson.room %} + <a href="{% url "timetable_smart_plan" "room" lesson.room.id %}"> + {{ lesson.room.shortcode }} </a> {% endif %} </span> - {% endif %} - {% endif %} - </p> - </div> + {% endif %} + {% endif %} + </p> + </div> - {% endfor %} - </div> + {% endfor %} + </div> </div> diff --git a/aleksis/apps/chronos/templates/chronos/plan.html b/aleksis/apps/chronos/templates/chronos/plan.html index d3812a21..11a92c55 100644 --- a/aleksis/apps/chronos/templates/chronos/plan.html +++ b/aleksis/apps/chronos/templates/chronos/plan.html @@ -211,10 +211,10 @@ </div> </div> - {% for weekday, lesson in lesson_periods_period.items %} + {% for weekday, lessons in lesson_periods_period.items %} {# A lesson #} <div class="col s2"> - {% include "chronos/lesson.html" %} + {% include "chronos/lesson.html" with lessons=lessons %} </div> {% endfor %} </div> -- GitLab