From cecd79f1c55900950378dffcb0639dab43f8fe41 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Mon, 5 Aug 2013 14:41:25 +0200 Subject: [PATCH] Allow multiple allocations for a topic Support creation of disjoint slots for a given topic, to support the new "scattered" topic layout we plan to use for HK. Change-Id: I9bd382c05234a58a162dbcbb7efced396d0ff7e9 --- scheduling/management/commands/loadslots.py | 4 ++-- slots.json.sample | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scheduling/management/commands/loadslots.py b/scheduling/management/commands/loadslots.py index c68663a..5aafca2 100644 --- a/scheduling/management/commands/loadslots.py +++ b/scheduling/management/commands/loadslots.py @@ -44,9 +44,9 @@ class Command(BaseCommand): r = Room(code=roomcode, name=roomdesc) r.save() - for topicname, desc in data['topics'].iteritems(): + for desc in data['allocations']: started = False - t = Topic.objects.get(name=topicname) + t = Topic.objects.get(name=desc['topic']) room = Room.objects.get(code=desc['room']) for (d, h) in slot_generator(data): if (d == desc['start_day'] and h == desc['first_slot']): diff --git a/slots.json.sample b/slots.json.sample index d69327c..cbaf504 100644 --- a/slots.json.sample +++ b/slots.json.sample @@ -21,10 +21,12 @@ ] } ], - "topics": { - "Swift": { + "allocations": [ + { + "topic": "Swift", "room": "A", "start_day": "2012-09-20", "first_slot": "09:30", - "end_day": "2012-09-21", "last_slot": "10:00" } - } + "end_day": "2012-09-21", "last_slot": "10:00" + } + ] }