From 283aa5d22bb2b1fe97fd0fc09c171267cdc56f68 Mon Sep 17 00:00:00 2001 From: Clinton Roy Date: Mon, 21 Oct 2019 22:17:57 +1000 Subject: [PATCH] make a slot for exclusive events with no allocated rooms, things like food breaks. --- .../management/commands/update_schedule.py | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/pinaxcon/registrasion/management/commands/update_schedule.py b/pinaxcon/registrasion/management/commands/update_schedule.py index a43228f6..762dc28b 100644 --- a/pinaxcon/registrasion/management/commands/update_schedule.py +++ b/pinaxcon/registrasion/management/commands/update_schedule.py @@ -55,11 +55,14 @@ class Command(BaseCommand): slot_type_count[(date, kind)] += 1 kindslot = f"{kind} {slot_type_count[(date, kind)]}" - for room in rooms.split(';'): - room = room.strip() - self.room_names.add(room) + if rooms.strip(): + for room in rooms.split(';'): + room = room.strip() + 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): self.talks = {} @@ -136,9 +139,7 @@ class Command(BaseCommand): assert preso, f"Could not find Presentation for talk {talk_id}" if not preso.slot: - - # TODO the exclusive list should not be hard coded, another csv file maybe. - exclusive = kind_name in ["plenary", "morning tea", "lunch", "afternoon tea"] + exclusive = self.exclusive(kind_name) preso.slot = Slot.objects.create( day=self.days[date], @@ -156,6 +157,24 @@ class Command(BaseCommand): slot=preso.slot, 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): self.parse_slots(options) self.parse_talks(options) @@ -166,3 +185,4 @@ class Command(BaseCommand): self.create_simple_models() self.create_complex_models() + self.create_exclusive_models()