From dcba2e692cf6c564233c8bbe1f581f67367f2d88 Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 7 May 2017 02:18:04 +0200 Subject: [PATCH] talk conflicts detect --- plugins/talks.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/talks.py b/plugins/talks.py index 5da0cd3..2a45373 100644 --- a/plugins/talks.py +++ b/plugins/talks.py @@ -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,