make a slot for exclusive events with no allocated rooms, things like food breaks.

This commit is contained in:
Clinton Roy 2019-10-21 22:17:57 +10:00
parent 249adba527
commit 283aa5d22b

View file

@ -55,12 +55,15 @@ class Command(BaseCommand):
slot_type_count[(date, kind)] += 1 slot_type_count[(date, kind)] += 1
kindslot = f"{kind} {slot_type_count[(date, kind)]}" kindslot = f"{kind} {slot_type_count[(date, kind)]}"
if rooms.strip():
for room in rooms.split(';'): for room in rooms.split(';'):
room = room.strip() room = room.strip()
self.room_names.add(room) self.room_names.add(room)
self.slot_details[(date, kindslot, room)] = (start_time, end_time) self.slot_details[(date, kindslot, room)] = (start_time, end_time)
elif self.exclusive(kind):
self.slot_details[(date, kindslot, None)] = (start_time, end_time)
def parse_talks(self, options): def parse_talks(self, options):
self.talks = {} self.talks = {}
@ -136,9 +139,7 @@ class Command(BaseCommand):
assert preso, f"Could not find Presentation for talk {talk_id}" assert preso, f"Could not find Presentation for talk {talk_id}"
if not preso.slot: if not preso.slot:
exclusive = self.exclusive(kind_name)
# TODO the exclusive list should not be hard coded, another csv file maybe.
exclusive = kind_name in ["plenary", "morning tea", "lunch", "afternoon tea"]
preso.slot = Slot.objects.create( preso.slot = Slot.objects.create(
day=self.days[date], day=self.days[date],
@ -156,6 +157,24 @@ class Command(BaseCommand):
slot=preso.slot, slot=preso.slot,
room=self.rooms[room_name]) room=self.rooms[room_name])
def create_exclusive_models(self):
for (date, kindslot, room) in self.slot_details.keys():
if room is None:
start_time, end_time = self.slot_details[(date, kindslot, room)]
kind_name = kindslot.rsplit(' ', 1)[0]
slot = Slot.objects.create(
day=self.days[date],
kind=self.slotkinds[kind_name],
start=start_time,
end=end_time,
exclusive=True)
slot.save()
def exclusive(self, kind_name):
# TODO the exclusive list should not be hard coded, another csv file maybe.
return kind_name in ["plenary", "morning tea", "lunch", "afternoon tea"]
def handle(self, *args, **options): def handle(self, *args, **options):
self.parse_slots(options) self.parse_slots(options)
self.parse_talks(options) self.parse_talks(options)
@ -166,3 +185,4 @@ class Command(BaseCommand):
self.create_simple_models() self.create_simple_models()
self.create_complex_models() self.create_complex_models()
self.create_exclusive_models()