From a7f26de2febca56fbb47153af7a450abde0284f9 Mon Sep 17 00:00:00 2001 From: Clinton Roy Date: Sun, 13 Oct 2019 14:54:07 +1100 Subject: [PATCH] making slots. --- .../management/commands/update_schedule.py | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/pinaxcon/registrasion/management/commands/update_schedule.py b/pinaxcon/registrasion/management/commands/update_schedule.py index 415a7828..8a971310 100644 --- a/pinaxcon/registrasion/management/commands/update_schedule.py +++ b/pinaxcon/registrasion/management/commands/update_schedule.py @@ -14,6 +14,7 @@ from collections import Counter from pathlib import Path import csv + class Command(BaseCommand): known_headers = ["date", "start time", "end time", "kind", "rooms"] SLOTS = 'slots' @@ -34,7 +35,7 @@ class Command(BaseCommand): date_strs = set() slotkind_names = set() room_names = set() - slot = {} + slot_details = {} slot_type_count = Counter() conf = current_conference() @@ -65,19 +66,19 @@ class Command(BaseCommand): assert kind, "kind cannot be blank" slot_type_count[(date, kind)] += 1 - slot_name = f"{kind} {slot_type_count[(date, kind)]}" + kindslot = f"{kind} {slot_type_count[(date, kind)]}" for room in rooms.split(';'): room = room.strip() room_names.add(room) - slot[(date, slot_name, room)] = self.find_or_create_slot( - date, start_time, end_time, room) + slot_details[(date, kindslot, room)] = (start_time, end_time) with open(options[self.TALKS]) as csv_file: csv_reader = csv.reader(csv_file) used_rooms = next(csv_reader) + talk = {} assert used_rooms[0] == '', "Cell (1, 1) must be empty" @@ -88,7 +89,7 @@ class Command(BaseCommand): cell = row[0] if cell.rsplit(' ', 1)[0] in slotkind_names: - kind = cell + kindslot = cell for i, room in enumerate(used_rooms[1:], 1): talk_id = row[i] @@ -96,10 +97,9 @@ class Command(BaseCommand): if not talk_id: continue - assert (date, kind, room) in slot, f"Slot ({date}, '{kind}', '{room}') not found" + assert (date, kindslot, room) in slot_details, f"Slot ({date}, '{kindslot}', '{room}') not found" - # TODO set the talk slot to the associated talk - # place_talk(slot[(date, slot_name)].talk = int(talk_id) + talk[(date, kindslot, room)] = int(talk_id) else: assert parse(row[0]), "Not a date: {row[0]}" @@ -114,14 +114,32 @@ class Command(BaseCommand): print('schedule', type(schedule)) day, _created = Day.objects.get_or_create( schedule=schedule, date=date) - days['date'] = day + days[date] = day + + print('days', days) rooms = {} for room_name in room_names: room, _created = Room.objects.get_or_create( schedule=schedule, name=room_name, order=used_rooms.index(room_name)) - slotkind = {} + slotkinds = {} for slotkind_name in slotkind_names: slotkind, _created = SlotKind.objects.get_or_create(schedule=schedule, label=slotkind_name) + slotkinds[slotkind_name] = slotkind + + for details in slot_details: + date, kindslot, room = details + start_time, end_time = slot_details[details] + + kind_name = kindslot.rsplit(' ', 1)[0] + + # TODO this should not be hard coded + exclusive = kind_name in ["plenary", "morning tea", "afternoon tea"] + + slot, _created = Slot.objects.get_or_create( + day=days[date], + kind=slotkinds[kind_name], + start=start_time, end=end_time, + exclusive=exclusive)