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

- Outsource sub generator and include it in lesson template

- Fix bug in smart plan generation
parent b2c7dd1a
No related branches found
No related tags found
1 merge request!86Merge school-apps
......@@ -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 %}
......
{% 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
{% 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
{% 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
......@@ -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 %}
......
......@@ -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:
......
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