Commit efdffeef authored by Andreas Valder's avatar Andreas Valder

fixed an off by one error in the timetable drawing closes #322 , closes #293

parent 347ecd44
......@@ -19,18 +19,24 @@
<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 %}
{% set time_loop = loop %}
{% set time_index = loop.index %}
<tr height="12px" {% if t.strftime("%M") == "00" %} class="hourlytime" {% endif %}>
{# display time in first row if its a full hour #}
{% if ((loop.index - 1) is divisibleby 4) %} <td rowspan="4" style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td> {% endif %}
{% if ((time_index - 1) is divisibleby 4) %} <td rowspan="4" style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td> {% endif %}
{# iterate over days if if it is a working day or we have lectures on that day (optionaly skip weekends) #}
{% for d in days if (d.index < 5) or (d.lectures|length) > 0 %}
{% for col in range(1,d.maxcol+1) %}
{# iterate over all lextures but only consider those that are in the current column and happen in the 15 min block #}
{% 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 ) ) %}
{# time_index starts at 0 so we use it directly and do not do +1 #}
{% for l in d.lectures|selectattr('timetable_col','equalto',col) if ((l.time.time() >= t) and (l.time.time() < times[time_index])) %}
{# handle the first column of a day specialy, set red background if hidden #}
<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 %}">
<td
{% if col == 1 %} class="newday"{% endif %}
{# we have to take into account that we might have rounded the start to 15-min intervalls #}
rowspan="{{ ( (l.duration + ( ((t.minute + t.hour*60) - (l.time.time().minute + l.time.time().hour *60 )) |abs ) ) / 15)|round(method="ceil")|int }}"
style="background: {% if l.visible and l.course.visible %}lightgrey;{% else %}#f2dede{% endif %}"
>
{# print the lecture block #}
<p class="small">
<strong>
......@@ -49,7 +55,7 @@
{% 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 #}
{# no lecture right now, just end column #}
<td {% if col == 1 %} class="newday"{% endif %}></td>
{% endfor %}
{% endfor %}
......
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