diff --git a/server.py b/server.py index 81d40c244ab1d723639f24d8a628b15ee0977c7d..77a00e7f2d35960ec0b66f355f8b9a30e68c8651 100755 --- a/server.py +++ b/server.py @@ -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') diff --git a/templates/macros.html b/templates/macros.html index 629a8d9246031110bdd67b1cad565302bf6c96bf..16579d28cf516f2616be77f3ae6938d4a97616a0 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -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> diff --git a/templates/schedule.html b/templates/schedule.html index 45b33f4eaa7ea2b42651a10307b9ae6866ca7c96..dbd4123463705f73214091cc3f330893b92bb92c 100644 --- a/templates/schedule.html +++ b/templates/schedule.html @@ -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>