talk conflicts detect

This commit is contained in:
boyska 2017-05-07 02:18:04 +02:00 committed by dbz
parent 27eb51e5a7
commit dcba2e692c

View file

@ -11,8 +11,9 @@ import re
import datetime
import shutil
import time
import markdown
from copy import copy
import markdown
from docutils import nodes
from docutils.parsers.rst import directives, Directive
@ -199,14 +200,21 @@ class TalkGridDirective(Directive):
for t in range(mintime, maxtime, GRID_STEP):
times[t] = [None] * len(rooms)
for talk in talks:
for talk in sorted(talks, key=lambda x: x['time']):
talktime = talk['time'].hour * 60 + talk['time'].minute
position = talktime // GRID_STEP * GRID_STEP # round
assert position in times
roomnum = rooms.index(talk['room'])
times[position][roomnum] = talk
if times[position][roomnum] is not None:
logging.error("Talk {} and {} overlap! "
.format(times[position][roomnum]['id'],
talk['id']))
continue
times[position][roomnum] = copy(talk)
times[position][roomnum]['skip'] = False
for i in range(1, talk['duration'] // GRID_STEP):
times[position + i*GRID_STEP][roomnum] = 'skip'
times[position + i*GRID_STEP][roomnum] = copy(talk)
times[position + i*GRID_STEP][roomnum]['skip'] = True
render = tmpl.render(times=times,
rooms=rooms,