Skip to content
Snippets Groups Projects
Verified Commit 32570814 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Show supervision substitutions in list/table views

In order to do that some parts has been refactored out in own templates.

Advances #73
parent b5c52a83
No related branches found
No related tags found
1 merge request!47Advanced data in timetable views
Showing
with 141 additions and 96 deletions
......@@ -45,14 +45,14 @@
{% endif %}
{# Display teacher with tooltip #}
{% include "chronos/partials/subs/teachers.html" %}
{% include "chronos/partials/subs/teachers.html" with type="substitution" el=sub %}
{# Display subject #}
{% include "chronos/partials/subs/subject.html" %}
{% include "chronos/partials/subs/subject.html" with type="substitution" el=sub %}
{# Teacher or class > display room #}
{% if type == "teacher" or type == "group" %}
{% include "chronos/partials/subs/room.html" %}
{% include "chronos/partials/subs/room.html" with type="substitution" el=sub %}
{% endif %}
{% endif %}
......
{% if item.type == "substitution" %}
{% if item.el.cancelled or item.el.cancelled_for_teachers %}
green-text
{% else %}
black-text
{% endif %}
{% elif item.type == "supervision_substitution" %}
blue-text
{% endif %}
<strong>
{% if type == "substitution" %}
{{ el.lesson_period.period.period }}.
{% elif type == "supervision_substitution" %}
{% with break=el.supervision.break_item %}
{{ break.after_period_number }}./{{ break.before_period_number }}.
{% endwith %}
{% endif %}
</strong>
{% if sub.cancelled or sub.cancelled_for_teachers %}
{# Canceled lesson: no room #}
{% elif sub.room and sub.lesson_period.room %}
{# New and old room available #}
<span class="tooltipped" data-position="bottom"
data-tooltip="{{ sub.lesson_period.room.name }} → {{ sub.lesson_period.room.name }}"
title="{{ sub.lesson_period.room.name }} → {{ sub.lesson_period.room.name }}">
<a href="{% url "timetable" "room" sub.lesson_period.room.pk %}">
<s>{{ sub.lesson_period.room.short_name }}</s>
</a>
<a href="{% url "timetable" "room" sub.room.pk %}">
<strong>{{ sub.room.short_name }}</strong>
</a>
</span>
{% elif sub.room and not sub.lesson_period.room %}
{# Only new room available #}
<span class="tooltipped" data-position="bottom"
data-tooltip="{{ sub.room.name }}"
title="{{ sub.room.name }}">
<a href="{% url "timetable" "room" sub.room.pk %}">
{{ sub.room.short_name }}
</a>
</span>
{% elif not sub.room and not sub.lesson_period.room %}
{# Nothing to view #}
{% else %}
{# Only old room available #}
<span class="tooltipped" data-position="bottom"
data-tooltip="{{ sub.lesson_period.room.name }}"
title="{{ sub.lesson_period.room.name }}">
<a href="{% url "timetable" "room" sub.lesson_period.room.pk %}">
{{ sub.lesson_period.room.short_name }}
</a>
</span>
{% if type == "substitution" %}
{% if el.cancelled or el.cancelled_for_teachers %}
{# Canceled lesson: no room #}
{% elif el.room and el.lesson_period.room %}
{# New and old room available #}
<span class="tooltipped" data-position="bottom"
data-tooltip="{{ el.lesson_period.room.name }} → {{ el.lesson_period.room.name }}"
title="{{ el.lesson_period.room.name }} → {{ el.lesson_period.room.name }}">
<a href="{% url "timetable" "room" el.lesson_period.room.pk %}">
<s>{{ el.lesson_period.room.short_name }}</s>
</a>
<a href="{% url "timetable" "room" el.room.pk %}">
<strong>{{ el.room.short_name }}</strong>
</a>
</span>
{% elif el.room and not el.lesson_period.room %}
{# Only new room available #}
<span class="tooltipped" data-position="bottom"
data-tooltip="{{ el.room.name }}"
title="{{ el.room.name }}">
<a href="{% url "timetable" "room" el.room.pk %}">
{{ el.room.short_name }}
</a>
</span>
{% elif not el.room and not el.lesson_period.room %}
{# Nothing to view #}
{% else %}
{# Only old room available #}
<span class="tooltipped" data-position="bottom"
data-tooltip="{{ el.lesson_period.room.name }}"
title="{{ el.lesson_period.room.name }}">
<a href="{% url "timetable" "room" el.lesson_period.room.pk %}">
{{ el.lesson_period.room.short_name }}
</a>
</span>
{% endif %}
{% elif type == "supervision_substitution" %}
{% with supervision=el.supervision %}
<span data-position="bottom" class="tooltipped"
data-tooltip="{{ supervision.area.name }}" title="{{ supervision.area.name }}">
{{ supervision.area.short_name }}
</span>
{% endwith %}
{% endif %}
{% load i18n %}
{% if not sub.lesson_period.lesson.subject and not sub.subject %}
{% elif sub.cancelled or sub.cancelled_for_teachers %}
<span data-position="bottom" class="tooltipped" data-tooltip="{{ sub.lesson_period.lesson.subject.name }}">
<s>{{ sub.lesson_period.lesson.subject.abbrev }}</s>
{% if type == "substitution" %}
{% if not el.lesson_period.lesson.subject and not el.subject %}
{% elif el.cancelled or el.cancelled_for_teachers %}
<span data-position="bottom" class="tooltipped" data-tooltip="{{ el.lesson_period.lesson.subject.name }}">
<s>{{ el.lesson_period.lesson.subject.abbrev }}</s>
</span>
{% elif sub.subject and sub.lesson_period.lesson.subject %}
<span data-position="bottom" class="tooltipped" data-tooltip="{{ sub.lesson_period.lesson.subject.name }}">
<s>{{ sub.lesson_period.lesson.subject.abbrev }}</s>
{% elif el.subject and el.lesson_period.lesson.subject %}
<span data-position="bottom" class="tooltipped" data-tooltip="{{ el.lesson_period.lesson.subject.name }}">
<s>{{ el.lesson_period.lesson.subject.abbrev }}</s>
</span>
<span data-position="bottom" class="tooltipped" data-tooltip="{{ sub.subject.name }}">
<strong>{{ sub.subject.abbrev }}</strong>
<span data-position="bottom" class="tooltipped" data-tooltip="{{ el.subject.name }}">
<strong>{{ el.subject.abbrev }}</strong>
</span>
{% elif sub.subject and not sub.lesson_period.lesson.subject %}
<span data-position="bottom" class="tooltipped" data-tooltip="{{ sub.subject.name }}">
<strong>{{ sub.subject.abbrev }}</strong>
{% elif el.subject and not el.lesson_period.lesson.subject %}
<span data-position="bottom" class="tooltipped" data-tooltip="{{ el.subject.name }}">
<strong>{{ el.subject.abbrev }}</strong>
</span>
{% else %}
<span data-position="bottom" class="tooltipped" data-tooltip="{{ sub.lesson_period.lesson.subject.name }}">
<strong>{{ sub.lesson_period.lesson.subject.abbrev }}</strong>
{% else %}
<span data-position="bottom" class="tooltipped" data-tooltip="{{ el.lesson_period.lesson.subject.name }}">
<strong>{{ el.lesson_period.lesson.subject.abbrev }}</strong>
</span>
{% endif %}
{% elif type == "supervision_substitution" %}
{% trans "Supervision" %}
{% endif %}
{% if sub.cancelled and sub.lesson_period.lesson.teachers.all %}
{% include "chronos/partials/teachers.html" with teachers=sub.lesson_period.lesson.teachers.all %}
{% elif sub.teachers.all and sub.lesson_period.lesson.teachers.all %}
{% if type == "substitution" %}
{% if el.cancelled and el.lesson_period.lesson.teachers.all %}
{% include "chronos/partials/teachers.html" with teachers=el.lesson_period.lesson.teachers.all %}
{% elif el.teachers.all and el.lesson_period.lesson.teachers.all %}
<s>
{% include "chronos/partials/teachers.html" with teachers=el.lesson_period.lesson.teachers.all %}
</s>
<strong>
{% include "chronos/partials/teachers.html" with teachers=el.teachers.all %}
</strong>
{% elif el.teachers.all and not el.lesson_period.lesson.teachers.all %}
{% include "chronos/partials/teachers.html" with teachers=el.teachers.all %}
{% elif el.lesson_period.lesson.teachers.all %}
{% include "chronos/partials/teachers.html" with teachers=el.lesson_period.lesson.teachers.all %}
{% endif %}
{% elif type == "supervision_substitution" %}
<s>
{% include "chronos/partials/teachers.html" with teachers=sub.lesson_period.lesson.teachers.all %}
{% include "chronos/partials/teachers.html" with teachers=el.supervision.teachers %}
</s>
<strong>
{% include "chronos/partials/teachers.html" with teachers=sub.teachers.all %}
{% include "chronos/partials/teachers.html" with teachers=el.teachers %}
</strong>
{% elif sub.teachers.all and not sub.lesson_period.lesson.teachers.all %}
{% include "chronos/partials/teachers.html" with teachers=sub.teachers.all %}
{% elif sub.lesson_period.lesson.teachers.all %}
{% include "chronos/partials/teachers.html" with teachers=sub.lesson_period.lesson.teachers.all %}
{% endif %}
......@@ -18,13 +18,7 @@
{{ supervision.area.short_name }}
</span>
{% if supervision.get_substitution and smart %}
<s>
{% include "chronos/partials/teachers.html" with teachers=supervision.teachers %}
</s>
<strong>
{% include "chronos/partials/teachers.html" with teachers=supervision.get_substitution.teachers %}
</strong>
{% include "chronos/partials/subs/teachers.html" with type="supervision_substitution" el=supervision.get_substitution %}
{% elif type == "supervision_area" %}
{% include "chronos/partials/teachers.html" with teachers=supervision.teachers %}
{% endif %}
......
......@@ -58,28 +58,24 @@
</td>
{% endif %}
{% for item in substitutions %}
<tr class="
{% if item.type == "substitution" %}
{% if item.el.cancelled or item.el.cancelled_for_teachers %}green-text{% else %}black-text{% endif %}
{% endif %}
">
{# TODO: Extend support for blue and purple (supervisions and events) #}
<tr class="{% include "chronos/partials/subs/colour.html" with item=item %}">
{# TODO: Extend support for purple (events) #}
<td>
{% include "chronos/partials/groups.html" with groups=item.el.lesson_period.lesson.groups.all %}
{% if item.type == "substitution" %}
{% include "chronos/partials/groups.html" with groups=item.el.lesson_period.lesson.groups.all %}
{% endif %}
</td>
<td>
<strong>
{{ item.el.lesson_period.period.period }}.
</strong>
{% include "chronos/partials/subs/period.html" with type=item.type el=item.el %}
</td>
<td>
{% include "chronos/partials/subs/teachers.html" with sub=item.el %}
{% include "chronos/partials/subs/teachers.html" with type=item.type el=item.el %}
</td>
<td>
{% include "chronos/partials/subs/subject.html" with sub=item.el %}
{% include "chronos/partials/subs/subject.html" with type=item.type el=item.el %}
</td>
<td>
{% include "chronos/partials/subs/room.html" with sub=item.el %}
{% include "chronos/partials/subs/room.html" with type=item.type el=item.el %}
</td>
<td>
<span class="hide-on-med-and-up">
......
......@@ -52,27 +52,23 @@
<tbody class="{% cycle "striped" "not-striped" %}">
{% endifchanged %}
<tr class="
{% if item.type == "substitution" %}
{% if item.el.cancelled or item.el.cancelled_for_teachers %}green-text{% else %}black-text{% endif %}
{% endif %}
">
<tr class="{% include "chronos/partials/subs/colour.html" with item=item %}">
<td>
{% include "chronos/partials/groups.html" with groups=item.el.lesson_period.lesson.groups.all %}
{% if item.type == "substitution" %}
{% include "chronos/partials/groups.html" with groups=item.el.lesson_period.lesson.groups.all %}
{% endif %}
</td>
<td>
<strong>
{{ item.el.lesson_period.period.period }}.
</strong>
{% include "chronos/partials/subs/period.html" with type=item.type el=item.el %}
</td>
<td>
{% include "chronos/partials/subs/teachers.html" with sub=item.el %}
{% include "chronos/partials/subs/teachers.html" with type=item.type el=item.el %}
</td>
<td>
{% include "chronos/partials/subs/subject.html" with sub=item.el %}
{% include "chronos/partials/subs/subject.html" with type=item.type el=item.el %}
</td>
<td>
{% include "chronos/partials/subs/room.html" with sub=item.el %}
{% include "chronos/partials/subs/room.html" with type=item.type el=item.el %}
</td>
<td>
{% include "chronos/partials/subs/badge.html" with sub=item.el %}
......
......@@ -12,6 +12,7 @@ TimePeriod = apps.get_model("chronos", "TimePeriod")
Break = apps.get_model("chronos", "Break")
Supervision = apps.get_model("chronos", "Supervision")
LessonSubstitution = apps.get_model("chronos", "LessonSubstitution")
SupervisionSubstitution = apps.get_model("chronos", "SupervisionSubstitution")
def build_timetable(
......@@ -180,4 +181,22 @@ def build_substitutions_list(wanted_day: date) -> List[dict]:
rows.append(row)
# Get supervision substitutions
super_subs = SupervisionSubstitution.objects.filter(date=wanted_day)
for super_sub in super_subs:
row = {
"type": "supervision_substitution",
"sort_a": "Z.{}".format(super_sub.teacher),
"sort_b": "{}".format(super_sub.supervision.break_item.after_period_number),
"el": super_sub
}
rows.append(row)
# Sort all items
def sorter(row: dict):
return row["sort_a"] + row["sort_b"]
rows.sort(key=sorter)
return rows
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment