diff --git a/server.py b/server.py index 7d4d3ac57f41380d082bc77c1ea25df860c8ca7e..e1c64e649794d1e55a26706812c0963859f42a27 100755 --- a/server.py +++ b/server.py @@ -1,7 +1,7 @@ #!/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]: