Commit 769f4cb5 authored by Andreas Valder's avatar Andreas Valder

schedule can now handle events that spawn multiple days

parent 4a6d90e1
......@@ -16,15 +16,20 @@ def schedule():
days.append({'date': days[i-1]['date'] + timedelta(days=1), 'atonce':0, 'index': i, 'lectures':[] })
for i in days:
# date and times are burning in sqlite
s = datetime.combine(i['date'],time())
s = datetime.combine(i['date'],time(0,0))
e = datetime.combine(i['date'],time(23,59))
i['lectures'] = query ('''
i['lectures'] = []
for l in query ('''
SELECT lectures.*,courses.short
FROM lectures
JOIN courses ON (lectures.course_id = courses.id)
WHERE (time < ?) AND (time > ?)
ORDER BY time ASC'''
,e,s);
ORDER BY time ASC'''):
# we can not use the where clause of sql to match against the time, because sqlite and mysql use a different syntax -.-
if ((l['time'] < e) and (l['time'] > s)) or ((l['time'] + timedelta(minutes=l['duration']) < e) and (l['time'] + timedelta(minutes=l['duration'])> s)):
i['lectures'].append(l)
oldtime = l['time']
l['time'] = max(s,l['time'])
l['duration'] = ( min(e,oldtime + timedelta(minutes=l['duration'])) - l['time'] ).total_seconds()/60
# sweepline to find out how many lectures overlap
maxcol=0;
curcol=0;
......
......@@ -24,7 +24,7 @@
{% 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 ) ) %}
<td rowspan="{{l.duration / 15}}" style="background: lightgrey;">
<p class="small">
<strong><a class="hidden-print" href="{{url_for('course', handle=l.handle)}}#lecture-{{l.id}}">{{l.short}}</a><span class="visible-print-inline">{{l.short}}</span></strong><br>
<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>
{{l.time.strftime("%H:%M")}} - {{l.time_end.strftime("%H:%M")}}<br>
{{l.place}}</p>
</td>
......
Markdown is supported
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