timetable.html 4.86 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 9 10 11 12 13 14
			{% if user %}
			<h1 class="panel-title">personalisierter Drehplan für {{ user.realname }}
					<a class="pull-right fa fa-calendar" aria-hidden="true" href="{{ url_for('ical_user', user=user.id) }}" style="text-decoration: none"></a>
				</h1>
			{% else %}
				<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>
			{% endif %}
Andreas Valder's avatar
Andreas Valder committed
15
		</div>
16
		<div class="hidden-print">
17
			<div style="margin-top: 10px; padding: 15px;" class="col-xs-12">
18 19 20 21 22 23 24 25 26
				{% if user %}
					<a href="{{url_for('timetable_user', user=user.id, kw=kw-1) }}" class="pull-left btn btn-default">{{ "<<" }}</a>
					<a href="{{url_for('timetable_user', user=user.id, kw=kw+1) }}" class="pull-right btn btn-default">{{ ">>" }}</a>
					<a href="{{url_for('timetable_user', user=user.id, kw=0) }}" style="width: 80px;" class="btn btn-default center-block">today</a>
				{% else %}
					<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="btn btn-default center-block">today</a>
				{% endif %}
27
			</div>
28 29 30 31
			<input id="weeksel" type="week" class="center-block" value="{{ weekofyear }}"/>
			<script>
				$( function () {
					$("#weeksel").on("change", function() {
32 33 34 35 36
						{% if user %}
							window.location.href="{{ url_for('timetable_user', user=user.id) }}?date="+$("#weeksel").val()
						{% else %}
							window.location.href="{{ url_for('timetable') }}?date="+$("#weeksel").val()
						{% endif %}
37 38 39
					});
				});
			</script>
40
		</div>
41
		<div class="panel-body row table-responsive">
42
			<table id="timetable" class="table table-bordered col-xs-12" style="width: auto; min-width: 100%;">
43
				<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>
44
				{# iterating over each 15 min block #}
45
				{% for t in times %}
46
					{% set time_index = loop.index %}
47
					<tr{% if t.strftime("%M") == "00" %} class="hourlytime"{% endif %}>
48
						{# display time in first row if its a full hour #}
49
						{% if ((time_index - 1) is divisibleby 4) %} <td{% if not loop.last %} rowspan="4"{% endif %} style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td>{% endif %}
50
						{# iterate over days if if it is a working day or we have lectures on that day (optionaly skip weekends) #}
51
						{% for d in days if (d.index < 5) or (d.lectures|length) > 0 %}
52 53 54
							{% 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 #}
55 56
								{# 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])) %}
57
									{# handle the first column of a day specialy, set red background if hidden #}
58 59 60 61 62 63
									<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 %}"
									>
64 65 66 67 68 69 70 71 72 73 74 75 76
										{# 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>
77
								{% else %}
78 79 80 81
									{# 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 %}
82
										{# no lecture right now, just end column #}
83 84
										<td {% if col == 1 %} class="newday"{% endif %}></td>
									{% endfor %}
85
								{% endfor %}
86 87
								{# end lecture #}

88
							{% endfor %}
89
							{# end day column #}
90
						{% endfor %}
91 92
						{# end day #}
					</tr>
93
				{% endfor %}
94
				{# end 15 min block #}
95
			</table>
Andreas Valder's avatar
Andreas Valder committed
96 97 98 99 100
		</div>
	</div>
</div>

{% endblock %}