diff --git a/server.py b/server.py index 91d0dc2c10b49af669cf230715f60be572b98c5a..09dc2cda4cef53c7c02fadc83c3c9f2db0bbac14 100644 --- a/server.py +++ b/server.py @@ -8,7 +8,6 @@ import sys import hashlib import random import sched -import time app = Flask(__name__) @@ -20,6 +19,7 @@ app.add_template_global(timedelta, name='timedelta') scheduler = sched.scheduler() def run_scheduler(): + import time time.sleep(1) # UWSGI does weird things on startup while True: scheduler.run() @@ -452,7 +452,7 @@ def sitemap(): import feeds import importer -import schedule +import timetable import sorter if 'ICAL_URL' in config: import meetings diff --git a/templates/schedule.html b/templates/timetable.html similarity index 71% rename from templates/schedule.html rename to templates/timetable.html index 6aa0ac969fc8e6e8d780a68aa5aefdd94ac3af14..25e10efbca25e5b9cbc2efeeec1ed7e998c551ac 100644 --- a/templates/schedule.html +++ b/templates/timetable.html @@ -7,9 +7,9 @@ </div> <div class="row hidden-print"> <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> + <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=0) }}" style="width: 80px;" class="center-block btn btn-default">today</a> </div> </div> <div class="panel-body row table-responsive"> @@ -21,7 +21,7 @@ {% if ((loop.index - 1) is divisibleby 4) %} <td rowspan="4" style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td> {% endif %} {% for d in days if (d.index < 5) or (d.lectures|length) > 0 %} {% for i in range(1,d.maxcol+1) %} - {% for l in d.lectures|selectattr('schedule_col','equalto',i) if (((l.time.time() > t) and (l.time.time() < times[time_loop.index+1])) != (l.time.time() == t ) ) %} + {% for l in d.lectures|selectattr('timetable_col','equalto',i) if (((l.time.time() > t) and (l.time.time() < times[time_loop.index+1])) != (l.time.time() == t ) ) %} <td rowspan="{{l.duration / 15}}" style="background: lightgrey;"> <p class="small"> <strong><a class="hidden-print" href="{{url_for('course', id=l.course_id)}}#lecture-{{l.id}}">{{l.short}}</a><span class="visible-print-inline">{{l.short}}</span></strong><br> @@ -29,7 +29,7 @@ {{l.place}}</p> </td> {% else %} - {% for l in d.lectures|selectattr('schedule_col','equalto',i) if (l.time.time() < t) and (l.time_end.time() > t) %} + {% for l in d.lectures|selectattr('timetable_col','equalto',i) if (l.time.time() < t) and (l.time_end.time() > t) %} {% else %} <td></td> {% endfor %} diff --git a/schedule.py b/timetable.py similarity index 91% rename from schedule.py rename to timetable.py index 0f3577c5a308478b3f13b82f72d9fb9fbceb3a0b..42faf95e27848f1f43a32433310042c8602f8520 100644 --- a/schedule.py +++ b/timetable.py @@ -1,9 +1,9 @@ from server import * -@app.route('/schedule') +@app.route('/timetable') @register_navbar('Drehplan', icon='calendar') @mod_required -def schedule(): +def timetable(): if 'kw' not in request.args: kw=0 else: @@ -44,12 +44,12 @@ def schedule(): maxcol = curcol if len(freecol) == 0: freecol.append(maxcol) - l[2]['schedule_col'] = freecol.pop() + l[2]['timetable_col'] = freecol.pop() if earlieststart > l[0].time(): earlieststart = l[0].time() else: curcol -= 1 - freecol.append(l[2]['schedule_col']) + freecol.append(l[2]['timetable_col']) if latestend < l[0].time(): latestend = l[0].time() i['maxcol'] = max(maxcol,1) @@ -59,4 +59,4 @@ def schedule(): 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,kw=kw) + return render_template('timetable.html',days=days,times=times,kw=kw)