timetable.html 3.54 KB
Newer Older
Andreas Valder's avatar
Andreas Valder committed
1 2 3 4
{% extends "base.html" %}
{% block content %}
<div class="panel-group" id="accordion">
	<div class="panel panel-default">
5
		<div class="hidden-print panel-heading">
6 7 8
			<h1 class="panel-title">Drehplan
				<a class="pull-right fa fa-calendar" aria-hidden="true" href="{{url_for('ical_all')}}" style="text-decoration: none"></a>
			</h1>
Andreas Valder's avatar
Andreas Valder committed
9
		</div>
10
		<div class="row hidden-print">
11
			<div  style="margin-top: 10px;" class="col-xs-12">
12 13 14
				<a href="{{url_for('timetable', kw=kw-1) }}" class="pull-left btn btn-default">{{ "<<" }}</a>
				<a href="{{url_for('timetable', kw=kw+1) }}" class="pull-right btn btn-default">{{ ">>" }}</a>
				<a href="{{url_for('timetable', kw=0) }}" style="width: 80px;" class="center-block btn btn-default">today</a>
15 16
			</div>
       		</div>
17
		<div class="panel-body row table-responsive" style="margin-left: 0px; margin-right: 0px; padding-left: 0px; padding-right: 0px">
18
			<table id="timetable" class="table table-bordered col-xs-12" style="width: auto; min-width: 100%;">
19
				<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>
20
				{# iterating over each 15 min block #}
21
				{% for t in times %}
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
					{% set time_loop = loop %}
					<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 %}
						{# 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 ) ) %}
									{# 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 %}">
										{# print the lecture block #}
										<p class="small">
											<strong>
												<a class="hidden-print" href="{{url_for('course', id=l.course_id)}}#lecture-{{l.id}}">
													{{l.course.short}}
												</a>
												<span class="visible-print-inline">{{l.course.short}}</span>
											</strong>
											<br>
											{{l.time.strftime("%H:%M")}} - {{l.time_end.strftime("%H:%M")}}<br>
											{{l.place}}
										</p>
									</td>
47
								{% else %}
48 49 50 51 52 53 54
									{# 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 %}
55
								{% endfor %}
56 57
								{# end lecture #}

58
							{% endfor %}
59
							{# end day column #}
60
						{% endfor %}
61 62
						{# end day #}
					</tr>
63
				{% endfor %}
64
				{# end 15 min block #}
65
			</table>
Andreas Valder's avatar
Andreas Valder committed
66 67 68 69 70 71
		</div>
	</div>
</div>
</div>

{% endblock %}