Commit 8fd47ad4 authored by Julian Rother's avatar Julian Rother
Browse files

Fixed problems introduced by adding schedule

parent ad7fd372
#!/bin/python
from flask import Flask, g, request, url_for, redirect, session, render_template, flash
from functools import wraps
from datetime import date, timedelta, datetime as dt, time
from datetime import date, timedelta, datetime, time
import os
app = Flask(__name__)
......@@ -197,7 +197,7 @@ def auth(): # For use with nginx auth_request
AND (? OR (courses.visible AND lectures.visible AND videos.visible))''',
url, ismod())
if videos and (url.startswith('pub') or ismod()):
query('INSERT INTO log VALUES (?, "", ?, "video", ?, ?)', ip, datetime.datetime.now(), videos[0]['id'], url)
query('INSERT INTO log VALUES (?, "", ?, "video", ?, ?)', ip, datetime.now(), videos[0]['id'], url)
return "OK", 200
elif url.endswith('jpg'):
return "OK", 200
......@@ -215,15 +215,15 @@ def schedule():
days.append({'date': days[i-1]['date'] + timedelta(days=1), 'lectures':[], 'atonce':0 })
for i in days:
# date and times are burning in sqlite
s = dt.combine(i['date'],time())
e = dt.combine(i['date'],time(23,59))
s = datetime.combine(i['date'],time())
e = datetime.combine(i['date'],time(23,59))
i['lectures'] = query ('SELECT lectures.*,courses.* FROM lectures JOIN courses ON (lectures.course_id = courses.id) WHERE (time < ?) AND (time > ?) ORDER BY time ASC',e,s);
# sweepline to find out how many lectures overlap
maxcol=0;
curcol=0;
freecol=[];
for l in i['lectures']:
l['time_asdate'] = dt.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'])
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]:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment