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 ...@@ -198,7 +198,11 @@ def auth(): # For use with nginx auth_request
@register_navbar('Drehplan', 'calendar') @register_navbar('Drehplan', 'calendar')
@mod_required @mod_required
def schedule(): 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 }] days = [{'date': start, 'lectures': [], 'atonce':0, 'index': 0 }]
earlieststart=time(23,59) earlieststart=time(23,59)
latestend=time(0,0) latestend=time(0,0)
...@@ -221,7 +225,8 @@ def schedule(): ...@@ -221,7 +225,8 @@ def schedule():
freecol=[]; freecol=[];
for l in i['lectures']: for l in i['lectures']:
l['time_asdate'] = datetime.strptime(l['time'],'%Y-%m-%d %H:%M:%S') 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])): 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]: if l[1]:
curcol += 1 curcol += 1
...@@ -240,12 +245,12 @@ def schedule(): ...@@ -240,12 +245,12 @@ def schedule():
i['maxcol'] = max(maxcol,1) i['maxcol'] = max(maxcol,1)
times=[] times=[]
s = min(earlieststart,time(8,0)) s = min(earlieststart,time(8,0))
e = max(latestend,time(20,0)) e = max(latestend,time(19,0))
for i in range(s.hour*4,int(60*e.hour/15)): 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('schedule.html',days=days,times=times) return render_template('schedule.html',days=days,times=times,kw=kw)
@app.route('/stats') @app.route('/stats')
@register_navbar('Statistiken', 'stats') @register_navbar('Statistiken', 'stats')
......
...@@ -130,6 +130,7 @@ $('#embedcodebtn').popover( ...@@ -130,6 +130,7 @@ $('#embedcodebtn').popover(
<li>{{ valueeditor(['lectures',lecture.id,'title'], lecture.title) }}</li> <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 %} {% 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>{{ valueeditor(['lectures',lecture.id,'time'], lecture.time) }} </li>
<li>Dauer: {{ valueeditor(['lectures',lecture.id,'duration'], lecture.duration) }} min</li>
{% if ismod() %} {% if ismod() %}
{% endif %} {% endif %}
</ul> </ul>
......
...@@ -5,6 +5,13 @@ ...@@ -5,6 +5,13 @@
<div class="panel-heading"> <div class="panel-heading">
<h1 class="panel-title">Drehplan</h1> <h1 class="panel-title">Drehplan</h1>
</div> </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"> <div class="panel-body row table-responsive">
<table class="table-bordered col-xs-12"> <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> <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