courses.html 2.84 KB
Newer Older
1
2
3
{% from 'macros.html' import course_list_item %}
{% extends "base.html" %}
{% block content %}
4
<div>
Andreas Valder's avatar
Andreas Valder committed
5
	<div class="col-xs-12" style="padding: 0px;">
6
7
		<ul class="list-inline pull-right">
			<li>
Andreas Valder's avatar
Andreas Valder committed
8
				 <a class="fa fa-rss-square btn btn-default" aria-hidden="true" href="{{url_for('courses_feed')}}" style="text-decoration: none"></a>
9
10
			</li>
			{% if ismod() %} 
11
12
13
			<li>
				<a class="fa fa-calendar btn btn-default" aria-hidden="true" href="{{url_for('ical_all')}}" style="text-decoration: none"></a>
			</li>
14
			<li>
Julian Rother's avatar
Julian Rother committed
15
16
				{% set newhandle = 'new'+(randint(0,1000)|string) %}
				<a class="btn btn-default" href="{{ url_for('create', table='courses', handle=newhandle, title='Neue Veranstaltung', responsible=session.user.givenName, ref=url_for('course', handle=newhandle)) }}">Neue Veranstaltung</a>
17
18
			</li>
			{% endif %}
19
			<li class="dropdown pull-right" style="padding-right: 0px">
20
21
22
23
24
				<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Gruppierung
					<span class="caret"></span>
				</button>
				<ul class="dropdown-menu dropdown-menu-right">
					<li><a href="?groupedby=semester">Semester</a></li>
Julian Rother's avatar
Julian Rother committed
25
26
27
					<li><a href="?groupedby=title">Veranstaltung</a></li>
					<li><a href="?groupedby=organizer">Dozent</a></li>
					<li><a href="?groupedby=subject">Kategorie</a></li>
28
29
				</ul>
			</li>
30
31
32
		</ul>
	</div>
</div>
Andreas Valder's avatar
Andreas Valder committed
33

34
<div class="visible-xs" id="xs-check"></div>
Andreas Valder's avatar
Andreas Valder committed
35
{% if groupedby == 'semester' %}
36
37
	{% set grouped_courses = courses|groupby(groupedby)|reverse|list %}
	<script>
Andreas Valder's avatar
Andreas Valder committed
38
		$(function () {
39
40
			if($("#xs-check").is(":visible")) {
				/* Only expand current semester */
41
				$(".collapse[id!='{{grouped_courses[1].grouper|tagid}}']").removeClass('in');
42
			}
Andreas Valder's avatar
Andreas Valder committed
43
		});
44
	</script>
Andreas Valder's avatar
Andreas Valder committed
45
{% else %}
46
47
	{% set grouped_courses = courses|groupby(groupedby)|list %}
	<script>
Andreas Valder's avatar
Andreas Valder committed
48
		$(function () {
49
50
51
			if($("#xs-check").is(":visible")) {
				$(".collapse[id!='{{grouped_courses[0].grouper|tagid}}']").removeClass('in');
			}
Andreas Valder's avatar
Andreas Valder committed
52
		});
53
	</script>
Andreas Valder's avatar
Andreas Valder committed
54
55
56
{% endif %}

{% for g in grouped_courses %}
57
<div class="row panel-group" id="accordion-{{ g.grouper|tagid }}">
58
59
	<div class="col-xs-12"><div class="panel panel-default">
		<div class="panel-heading">
60
			<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion-{{ g.grouper|tagid }}" href="#{{g.grouper|tagid}}" style="color: #222;">
61
				{% if groupedby == 'semester' %}
62
63
				<h1 class="panel-title">{{g.grouper|semester(long=True)}} ({{g.list|length}} Veranstaltungen)
				</h1>
64
65
66
67
				{% else %}
				<h1 class="panel-title">{{g.grouper}}</h1>
				{% endif %}
			</a>
68
		</div>
69
		<ul class="{% if not ismod() %}courses-list {% endif %}list-group panel-collapse collapse in" id="{{g.grouper|tagid}}">
70
			{% for i in g.list %}
71
72
73
				{% if groupedby == 'semester' %}
					{{ course_list_item(i) }}
				{% else %}
74
					{{ course_list_item(i, true) }}
75
76
77
78
79
				{% endif %}
			{% endfor %}
		</ul>
	</div></div>
</div>
80
{% endfor %}
81
{% endblock %}