Commit 51b2b604 authored by Andreas Valder's avatar Andreas Valder

fixed timetable display bug when displaying a not 15-min aligned lecture closes #242

parent 37003acb
...@@ -15,36 +15,51 @@ ...@@ -15,36 +15,51 @@
<div class="panel-body row table-responsive" style="margin-left: 0px; margin-right: 0px; padding-left: 0px; padding-right: 0px"> <div class="panel-body row table-responsive" style="margin-left: 0px; margin-right: 0px; padding-left: 0px; padding-right: 0px">
<table id="timetable" class="table table-bordered col-xs-12" style="width: auto; min-width: 100%;"> <table id="timetable" class="table table-bordered col-xs-12" style="width: auto; min-width: 100%;">
<tr><th style="width: 30px;"></th>{% for d in days if (d.index < 5) or (d.lectures|length) > 0 %}<th style="min-width: 10em;" colspan="{{d.maxcol}}">{{ d.date.strftime("%A (%d.%m.%Y)") }}</th>{% endfor %}</tr> <tr><th style="width: 30px;"></th>{% for d in days if (d.index < 5) or (d.lectures|length) > 0 %}<th style="min-width: 10em;" colspan="{{d.maxcol}}">{{ d.date.strftime("%A (%d.%m.%Y)") }}</th>{% endfor %}</tr>
{# iterating over each 15 min block #}
{% for t in times %} {% for t in times %}
{% set time_loop = loop %} {% set time_loop = loop %}
<tr height="12px" {% if t.strftime("%M") == "00" %} class="hourlytime" {% endif %}> <tr height="12px" {% if t.strftime("%M") == "00" %} class="hourlytime" {% endif %}>
{% if ((loop.index - 1) is divisibleby 4) %} <td rowspan="4" style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td> {% endif %} {# display time in first row if its a full hour #}
{% for d in days if (d.index < 5) or (d.lectures|length) > 0 %} {% if ((loop.index - 1) is divisibleby 4) %} <td rowspan="4" style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td> {% endif %}
{% for i in range(1,d.maxcol+1) %} {# iterate over days if if it is a working day or we have lectures on that day (optionaly skip weekends) #}
{% for l in d.lectures|selectattr('timetable_col','equalto',i) if (((l.time.time() > t) and (l.time.time() < times[time_loop.index+1])) != (l.time.time() == t ) ) %} {% for d in days if (d.index < 5) or (d.lectures|length) > 0 %}
<td {% if i == 1 %} class="newday"{% endif %} rowspan="{{l.duration / 15}}" style="background: {% if l.visible and l.course.visible %}lightgrey;{% else %}#f2dede{% endif %}"> {% for col in range(1,d.maxcol+1) %}
<p class="small">
<strong> {# iterate over all lextures but only consider those that are in the current column and happen in the 15 min block #}
<a class="hidden-print" href="{{url_for('course', id=l.course_id)}}#lecture-{{l.id}}"> {% for l in d.lectures|selectattr('timetable_col','equalto',col) if (((l.time.time() > t) and (l.time.time() < times[time_loop.index+1])) != (l.time.time() == t ) ) %}
{{l.course.short}} {# handle the first column of a day specialy, set red background if hidden #}
</a> <td {% if col == 1 %} class="newday"{% endif %} rowspan="{{ (l.duration / 15)|round(method="ceil") }}" style="background: {% if l.visible and l.course.visible %}lightgrey;{% else %}#f2dede{% endif %}">
<span class="visible-print-inline">{{l.course.short}}</span> {# print the lecture block #}
</strong> <p class="small">
<br> <strong>
{{l.time.strftime("%H:%M")}} - {{l.time_end.strftime("%H:%M")}}<br> <a class="hidden-print" href="{{url_for('course', id=l.course_id)}}#lecture-{{l.id}}">
{{l.place}} {{l.course.short}}
</p> </a>
</td> <span class="visible-print-inline">{{l.course.short}}</span>
{% else %} </strong>
{% for l in d.lectures|selectattr('timetable_col','equalto',i) if (l.time.time() < t) and (l.time_end.time() > t) %} <br>
{{l.time.strftime("%H:%M")}} - {{l.time_end.strftime("%H:%M")}}<br>
{{l.place}}
</p>
</td>
{% else %} {% else %}
<td {% if i == 1 %} class="newday"{% endif %}></td> {# if the lecture is in the current collumn but not the current time slot #}
{% for l in d.lectures|selectattr('timetable_col','equalto',col) if (l.time.time() < t) and (l.time_end.time() > t) %}
{# this part is covered by another lecture using rowspan #}
{% else %}
{# no lecture right now, jsut end column #}
<td {% if col == 1 %} class="newday"{% endif %}></td>
{% endfor %}
{% endfor %} {% endfor %}
{# end lecture #}
{% endfor %} {% endfor %}
{# end day column #}
{% endfor %} {% endfor %}
{% endfor %} {# end day #}
</tr> </tr>
{% endfor %} {% endfor %}
{# end 15 min block #}
</table> </table>
</div> </div>
</div> </div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment