Skip to content
Snippets Groups Projects
Commit 621f4936 authored by Andreas Valder's avatar Andreas Valder
Browse files

added the option for the timetable to select a date or pass a date as parameter

parent efdffeef
No related branches found
No related tags found
No related merge requests found
...@@ -7,20 +7,28 @@ ...@@ -7,20 +7,28 @@
<a class="pull-right fa fa-calendar" aria-hidden="true" href="{{url_for('ical_all')}}" style="text-decoration: none"></a> <a class="pull-right fa fa-calendar" aria-hidden="true" href="{{url_for('ical_all')}}" style="text-decoration: none"></a>
</h1> </h1>
</div> </div>
<div class="row hidden-print"> <div class="hidden-print">
<div style="margin-top: 10px;" class="col-xs-12"> <div style="margin-top: 10px; padding: 15px;" class="col-xs-12">
<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-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=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> <a href="{{url_for('timetable', kw=0) }}" style="width: 80px;" class="btn btn-default center-block">today</a>
</div> </div>
<input id="weeksel" type="week" class="center-block" value="{{ weekofyear }}"/>
<script>
$( function () {
$("#weeksel").on("change", function() {
window.location.href="{{ url_for('timetable') }}?date="+$("#weeksel").val()
});
});
</script>
</div> </div>
<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">
<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 #} {# iterating over each 15 min block #}
{% for t in times %} {% for t in times %}
{% set time_index = loop.index %} {% set time_index = loop.index %}
<tr height="12px" {% if t.strftime("%M") == "00" %} class="hourlytime" {% endif %}> <tr{% if t.strftime("%M") == "00" %} class="hourlytime"{% endif %}>
{# display time in first row if its a full hour #} {# display time in first row if its a full hour #}
{% if ((time_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) #} {# iterate over days if if it is a working day or we have lectures on that day (optionaly skip weekends) #}
...@@ -72,6 +80,5 @@ ...@@ -72,6 +80,5 @@
</div> </div>
</div> </div>
</div> </div>
</div>
{% endblock %} {% endblock %}
...@@ -5,6 +5,28 @@ from server import * ...@@ -5,6 +5,28 @@ from server import *
@mod_required @mod_required
def timetable(): def timetable():
if 'kw' not in request.args: if 'kw' not in request.args:
if 'date' in request.args:
thisweekmonday = datetime.now()
thisweekmonday -= timedelta(days=thisweekmonday.weekday())
try:
datesweekmonday = datetime.strptime(request.args['date'], '%d-%m-%Y')
except ValueError:
datesweekmonday = None
if not datesweekmonday:
try:
datesweekmonday = datetime.strptime(request.args['date'] + '-1', "%Y-W%W-%w")
except ValueError:
datesweekmonday = None
if not datesweekmonday:
kw = 0
weekofyear = str(datetime.today().year) + "-W" + str(datetime.today().isocalendar()[1])
else:
datesweekmonday -= timedelta(days=datesweekmonday.weekday())
weekofyear = str(datesweekmonday.year) + "-W" + str(datesweekmonday.isocalendar()[1])
kw = int((datesweekmonday.date() - thisweekmonday.date()).days/7)
else:
kw=0 kw=0
else: else:
kw=int(request.args['kw']) kw=int(request.args['kw'])
...@@ -79,4 +101,4 @@ def timetable(): ...@@ -79,4 +101,4 @@ def timetable():
for i in range(s.hour*4,min(int((60*e.hour/15)/4)*4+5,24*4)): for i in range(s.hour*4,min(int((60*e.hour/15)/4)*4+5,24*4)):
t = i*15 t = i*15
times.append(time(int(t/60),t%60)) times.append(time(int(t/60),t%60))
return render_template('timetable.html',days=days,times=times,kw=kw) return render_template('timetable.html',days=days,times=times,kw=kw, weekofyear=weekofyear)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment