diff --git a/schoolapps/timetable/templates/timetable/lesson.html b/schoolapps/timetable/templates/timetable/lesson.html index 1eda3c99c009aa43eaeba34f58de7ea0f1bdcd17..610635d4bc019ffe4a8606647952783c8090de90 100644 --- a/schoolapps/timetable/templates/timetable/lesson.html +++ b/schoolapps/timetable/templates/timetable/lesson.html @@ -26,10 +26,12 @@ {# 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 }}</a></span> - <br> + <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 }}</a> + </span> + <br> {% endif %} {% endif %} @@ -40,24 +42,24 @@ {% else %} {# Display sub #} + {% with sub=element_container.substitution %} - {# Teacher or room > display classes #} - {% if type == 0 or type == 1 %} - {{ element_container.substitution.table.classes }} - {% endif %} + {# Teacher or room > display classes #} + {% if type == 0 or type == 1 %} + {{ element_container.substitution.table.classes }} + {% endif %} - {# Display teacher with tooltip #} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ element_container.substitution.table.teacher_full|safe }}">{{ element_container.substitution.table.teacher|safe }}</span> + {# Display teacher with tooltip #} + {% include "timetable/subs/teacher.html" %} - {# Display subject #} - {{ element_container.substitution.table.subject|safe }} + {# Display subject #} + {% include "timetable/subs/subject.html" %} - {# Teacher or class > display room #} - {% if type == 0 or type == 2 %} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ element_container.substitution.table.room_full|safe }}">{{ element_container.substitution.table.room|safe }}</span> - {% endif %} + {# Teacher or class > display room #} + {% if type == 0 or type == 2 %} + {% include "timetable/subs/room.html" %} + {% endif %} + {% endwith %} {% endif %}<br> {# When it isn't a room or the old plan, then display the extra text (e. g. work orders)#} @@ -84,12 +86,12 @@ {# 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 }} - </a> - </span> + <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 }} + </a> + </span> {% endif %} {% endif %} @@ -100,11 +102,11 @@ {% 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 }} - </a> - {% endif %} + {% if element_container.room %} + <a href="{% url "timetable_smart_plan" "room" element_container.room.id %}"> + {{ element_container.room.shortcode }} + </a> + {% endif %} </span> {% endif %} {% endif %} diff --git a/schoolapps/timetable/templates/timetable/subs/room.html b/schoolapps/timetable/templates/timetable/subs/room.html new file mode 100644 index 0000000000000000000000000000000000000000..0d023430bcae2e8c4f0b4a99e2edb6a3ffe4a61f --- /dev/null +++ b/schoolapps/timetable/templates/timetable/subs/room.html @@ -0,0 +1,36 @@ +{% if sub.sub.type == 3 %} + {# Supervisement #} + {{ sub.sub.corridor.name }} +{% elif sub.sub.type == 1 or sub.sub.type == 2 %} + {# Canceled lesson: no room #} +{% elif sub.sub.roow_new and sub.sub.room_old %} + {# New and old room available #} + <span class="tooltipped" data-position="bottom" + data-tooltip="{{ sub.sub.room_old.name }} → {{ sub.sub.room_new.name }}"> + <a href="{% url "timetable_smart_plan" "room" sub.sub.room_old.id %}"> + <s>{{ sub.sub.room_old.shortcode }}</s> + </a> + → + <a href="{% url "timetable_smart_plan" "room" sub.sub.room_new.id %}"> + <strong>{{ sub.sub.room_new.shortcode }}</strong> + </a> + </span> +{% elif sub.sub.room_new and not sub.sub.room_old %} + {# Only new room available #} + <span class="tooltipped" data-position="bottom" + data-tooltip="{{ sub.sub.room_new.name }}"> + <a href="{% url "timetable_smart_plan" "room" sub.sub.room_new.id %}"> + {{ sub.sub.room_new.shortcode }} + </a> + </span> +{% elif not sub.sub.room_new and not sub.sub.room_old %} + {# Nothing to view #} +{% else %} + {# Only old room available #} + <span class="tooltipped" data-position="bottom" + data-tooltip="{{ sub.sub.room_old.name }}"> + <a href="{% url "timetable_smart_plan" "room" sub.sub.room_old.id %}"> + {{ sub.sub.room_old.shortcode }} + </a> + </span> +{% endif %} \ No newline at end of file diff --git a/schoolapps/timetable/templates/timetable/subs/subject.html b/schoolapps/timetable/templates/timetable/subs/subject.html new file mode 100644 index 0000000000000000000000000000000000000000..84be3ef4034bb521774c23657d2fb75ed674f4c8 --- /dev/null +++ b/schoolapps/timetable/templates/timetable/subs/subject.html @@ -0,0 +1,13 @@ +{% if sub.sub.type == 3 %} + <strong>Aufsicht</strong> +{% elif not sub.sub.subject_new and not sub.sub.subject_old %} +{% elif sub.sub.type == 1 or sub.sub.type == 2 %} + <s>{{ sub.sub.subject_old.shortcode }}</s> +{% elif sub.sub.subject_new and sub.sub.subject_old %} + <s>{{ sub.sub.subject_old.shortcode }}</s> → + <strong>{{ sub.sub.subject_new.shortcode }}</strong> +{% elif sub.sub.subject_new and not sub.sub.subject_old %} + <strong>{{ sub.sub.subject_new.shortcode }}</strong> +{% else %} + <strong>{{ sub.sub.subject_old.shortcode }}</strong> +{% endif %} \ No newline at end of file diff --git a/schoolapps/timetable/templates/timetable/subs/teacher.html b/schoolapps/timetable/templates/timetable/subs/teacher.html new file mode 100644 index 0000000000000000000000000000000000000000..f28e03745cf3ffba220abd979b8073a09353a52d --- /dev/null +++ b/schoolapps/timetable/templates/timetable/subs/teacher.html @@ -0,0 +1,33 @@ +{% if sub.sub.type == 1 %} + <span class="tooltipped" data-position="bottom" + data-tooltip="{{ sub.sub.teacher_old.name }}"> + <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_old.id %}"> + <s>{{ sub.sub.teacher_old.shortcode }}</s> + </a> + </span> +{% elif sub.sub.teacher_new and sub.sub.teacher_old %} + <span class="tooltipped" data-position="bottom" + data-tooltip="{{ sub.sub.teacher_old.name }} → {{ sub.sub.teacher_new.name }}"> + <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_old.id %}"> + <s>{{ sub.sub.teacher_old.shortcode }}</s> + </a> + → + <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_new.id %}"> + <strong>{{ sub.sub.teacher_new.shortcode }}</strong> + </a> + </span> +{% elif sub.sub.teacher_new and not sub.sub.teacher_old %} + <span class="tooltipped" data-position="bottom" + data-tooltip="{{ sub.sub.teacher_new.name }}"> + <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_new.id %}"> + <strong>{{ sub.sub.teacher_new.shortcode }}</strong> + </a> + </span> +{% elif sub.sub.teacher_old %} + <span class="tooltipped" data-position="bottom" + data-tooltip="{{ sub.sub.teacher_old.name }}"> + <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_old.id %}"> + <strong>{{ sub.sub.teacher_old.shortcode }}</strong> + </a> + </span> +{% endif %} \ No newline at end of file diff --git a/schoolapps/timetable/templates/timetable/substitution.html b/schoolapps/timetable/templates/timetable/substitution.html index 0a23353ff1567c438b394c00a21efc099119bc98..ef1010e1ce9b7034a969816e7505a20741a8711d 100755 --- a/schoolapps/timetable/templates/timetable/substitution.html +++ b/schoolapps/timetable/templates/timetable/substitution.html @@ -47,99 +47,13 @@ </strong> </td> <td> - {% if sub.sub.type == 1 %} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ sub.sub.teacher_old.name }}"> - <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_old.id %}"> - <s>{{ sub.sub.teacher_old.shortcode }}</s> - </a> - </span> - {% elif sub.sub.teacher_new and sub.sub.teacher_old %} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ sub.sub.teacher_old.name }} → {{ sub.sub.teacher_new.name }}"> - <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_old.id %}"> - <s>{{ sub.sub.teacher_old.shortcode }}</s> - </a> - → - <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_new.id %}"> - <strong>{{ sub.sub.teacher_new.shortcode }}</strong> - </a> - </span> - {% elif sub.sub.teacher_new and not sub.sub.teacher_old %} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ sub.sub.teacher_new.name }}"> - <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_new.id %}"> - <strong>{{ sub.sub.teacher_new.shortcode }}</strong> - </a> - </span> - {% elif sub.sub.teacher_old %} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ sub.sub.teacher_old.name }}"> - <a href="{% url "timetable_smart_plan" "teacher" sub.sub.teacher_old.id %}"> - <strong>{{ sub.sub.teacher_old.shortcode }}</strong> - </a> - </span> - {% endif %} - {# <span class="tooltipped" data-position="bottom"#} - {# data-tooltip="{{ sub.teacher_full|safe }}">{{ sub.teacher|safe }}</span>#} + {% include "timetable/subs/teacher.html" %} </td> <td> - {% if sub.sub.type == 3 %} - <strong>Aufsicht</strong> - {% elif not sub.sub.subject_new and not sub.sub.subject_old %} - {% elif sub.sub.type == 1 or sub.sub.type == 2 %} - <s>{{ sub.sub.subject_old.shortcode }}</s> - {% elif sub.sub.subject_new and sub.sub.subject_old %} - <s>{{ sub.sub.subject_old.shortcode }}</s> → - <strong>{{ sub.sub.subject_new.shortcode }}</strong> - {% elif sub.sub.subject_new and not sub.sub.subject_old %} - <strong>{{ sub.sub.subject_new.shortcode }}</strong> - {% else %} - <strong>{{ sub.sub.subject_old.shortcode }}</strong> - {% endif %} - {# {{ sub.subject|safe }}#} + {% include "timetable/subs/subject.html" %} </td> <td> - {% if sub.sub.type == 3 %} - {# Supervisement #} - {{ sub.sub.corridor.name }} - {% elif sub.sub.type == 1 or sub.sub.type == 2 %} - {# Canceled lesson: no room #} - {% elif sub.sub.roow_new and sub.sub.room_old %} - {# New and old room available #} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ sub.sub.room_old.name }} → {{ sub.sub.room_new.name }}"> - <a href="{% url "timetable_smart_plan" "room" sub.sub.room_old.id %}"> - <s>{{ sub.sub.room_old.shortcode }}</s> - </a> - → - <a href="{% url "timetable_smart_plan" "room" sub.sub.room_new.id %}"> - <strong>{{ sub.sub.room_new.shortcode }}</strong> - </a> - </span> - {% elif sub.sub.room_new and not sub.sub.room_old %} - {# Only new room available #} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ sub.sub.room_new.name }}"> - <a href="{% url "timetable_smart_plan" "room" sub.sub.room_new.id %}"> - {{ sub.sub.room_new.shortcode }} - </a> - </span> - {% elif not sub.sub.room_new and not sub.sub.room_old %} - {# Nothing to view #} - {% else %} - {# Only old room available #} - <span class="tooltipped" data-position="bottom" - data-tooltip="{{ sub.sub.room_old.name }}"> - <a href="{% url "timetable_smart_plan" "room" sub.sub.room_old.id %}"> - {{ sub.sub.room_old.shortcode }} - </a> - </span> - {% endif %} - {# <span class="tooltipped" data-position="bottom"#} - {# data-tooltip="{{ sub.sub.room }}">#} - {# {{ sub.sub.room }}#} - {# </span>#} + {% include "timetable/subs/room.html" %} </td> <td> {% if sub.badge %} diff --git a/schoolapps/untisconnect/plan.py b/schoolapps/untisconnect/plan.py index c87e0431769000c7f698110e9d216914f71b2132..a6065a048e7a9cc526a679e36cd7d2b19afb30e4 100644 --- a/schoolapps/untisconnect/plan.py +++ b/schoolapps/untisconnect/plan.py @@ -184,6 +184,10 @@ def get_plan(type, id, smart=False, monday_of_week=None): if sub["sub"].teacher_new.id == id: found = True + if sub["sub"].teacher_old: + if sub["sub"].teacher_old.id == id: + found = True + elif type == TYPE_ROOM: if sub["sub"].room_new: if sub["sub"].room_new.id == id: