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

made it posible to select the week to schow in the schedule

fixed bugs
who the hell inserts lectures with zero duration?!?
parent 0a813aeb
No related branches found
No related tags found
No related merge requests found
......@@ -198,7 +198,11 @@ def auth(): # For use with nginx auth_request
@register_navbar('Drehplan', 'calendar')
@mod_required
def schedule():
start = date.today() - timedelta(days=date.today().weekday()+7*20)
if 'kw' not in request.args:
kw=0
else:
kw=int(request.args['kw'])
start = date.today() - timedelta(days=date.today().weekday() -7*kw)
days = [{'date': start, 'lectures': [], 'atonce':0, 'index': 0 }]
earlieststart=time(23,59)
latestend=time(0,0)
......@@ -221,7 +225,8 @@ def schedule():
freecol=[];
for l in i['lectures']:
l['time_asdate'] = datetime.strptime(l['time'],'%Y-%m-%d %H:%M:%S')
l['end_asdate'] = l['time_asdate']+timedelta(minutes=l['duration'])
# who the hell inserts lectures with zero length?!?!?
l['end_asdate'] = l['time_asdate']+timedelta(minutes=max(l['duration'],1))
for l in sorted([(l['time_asdate'],True,l) for l in i['lectures']] + [(l['end_asdate'],False,l) for l in i['lectures']],key=lambda t:(t[0],t[1])):
if l[1]:
curcol += 1
......@@ -240,12 +245,12 @@ def schedule():
i['maxcol'] = max(maxcol,1)
times=[]
s = min(earlieststart,time(8,0))
e = max(latestend,time(20,0))
for i in range(s.hour*4,int(60*e.hour/15)):
e = max(latestend,time(19,0))
for i in range(s.hour*4,min(int((60*e.hour/15)/4)*4+5,24*4)):
t = i*15
times.append(time(int(t/60),t%60))
return render_template('schedule.html',days=days,times=times)
return render_template('schedule.html',days=days,times=times,kw=kw)
@app.route('/stats')
@register_navbar('Statistiken', 'stats')
......
......@@ -130,6 +130,7 @@ $('#embedcodebtn').popover(
<li>{{ valueeditor(['lectures',lecture.id,'title'], lecture.title) }}</li>
{% if lecture.speaker or ismod() %}<li>Gehalten von {{ valueeditor(['lectures',lecture.id,'speaker'], lecture.speaker) }}</li>{% endif %}
<li>{{ valueeditor(['lectures',lecture.id,'time'], lecture.time) }} </li>
<li>Dauer: {{ valueeditor(['lectures',lecture.id,'duration'], lecture.duration) }} min</li>
{% if ismod() %}
{% endif %}
</ul>
......
......@@ -5,6 +5,13 @@
<div class="panel-heading">
<h1 class="panel-title">Drehplan</h1>
</div>
<div class="row">
<div style="margin-top: 10px;" class="col-xs-12">
<a href="{{url_for('schedule', kw=kw-1) }}" class="pull-left btn btn-default">{{ "<<" }}</a>
<a href="{{url_for('schedule', kw=kw+1) }}" class="pull-right btn btn-default">{{ ">>" }}</a>
<a href="{{url_for('schedule', kw=0) }}" style="width: 80px;" class="center-block btn btn-default">today</a>
</div>
</div>
<div class="panel-body row table-responsive">
<table class="table-bordered col-xs-12">
<tr><th></th>{% for d in days if (d.index < 5) or (d.lectures|length) > 0%}<th colspan="{{d.maxcol}}">{{ d.date.strftime("%A (%d.%m.%Y)") }}</th>{% endfor %}</tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment