From 20469223cb057dc1bb4c8210d052b7ecd167d54a 2019-10-19 01:38:29 From: Clinton Roy Date: 2019-10-19 01:38:29 Subject: [PATCH] go from proposal, to presentation, to slot, to slotroom. --- diff --git a/pinaxcon/registrasion/management/commands/update_schedule.py b/pinaxcon/registrasion/management/commands/update_schedule.py index 20e232103c75158955a2d7530a53fa790f569084..c00009874664f99d108cd80e4005993750001358 100644 --- a/pinaxcon/registrasion/management/commands/update_schedule.py +++ b/pinaxcon/registrasion/management/commands/update_schedule.py @@ -116,33 +116,11 @@ class Command(BaseCommand): slotkind, _created = SlotKind.objects.get_or_create(schedule=schedule, label=slotkind_name) slotkinds[slotkind_name] = slotkind - slots = {} - 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) - - slots[(date, kind_name, start_time, end_time)] = slot - for details, talk_id in talks.items(): - date, kindslot, room = details + date, kindslot, room_name = details kind_name = kindslot.rsplit(' ', 1)[0] - (start_time, end_time) = slot_details[(date, kindslot, room)] - - slot = slots[(date, kind_name, start_time, end_time)] - - slotroom = SlotRoom.objects.get_or_create(slot=slot, room=rooms[room]) + (start_time, end_time) = slot_details[(date, kindslot, room_name)] proposal = ProposalBase.objects.filter(pk=talk_id).first() @@ -150,7 +128,20 @@ class Command(BaseCommand): preso = Presentation.objects.filter(proposal_base=proposal).first() - print(f'would like to set {preso} to slot {slot}') + 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"] + + preso.slot, _created = Slot.objects.get_or_create( + day=days[date], + kind=slotkinds[kind_name], + start=start_time, + end=end_time, + exclusive=exclusive) - #preso.slot = slot preso.save() + + slotroom, _create = SlotRoom.objects.get_or_create(slot=preso.slot, room=rooms[room_name])