diff --git a/schedule.py b/schedule.py index 5961d051142a6d6dce438875825477e130bbeb0a..0f3577c5a308478b3f13b82f72d9fb9fbceb3a0b 100644 --- a/schedule.py +++ b/schedule.py @@ -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; diff --git a/templates/schedule.html b/templates/schedule.html index af913fc1795576f8272c0531c96f9e418ab87b76..6aa0ac969fc8e6e8d780a68aa5aefdd94ac3af14 100644 --- a/templates/schedule.html +++ b/templates/schedule.html @@ -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>