first stab at linking presentations to slots.
This commit is contained in:
parent
1243e499e3
commit
92adbb3314
1 changed files with 27 additions and 19 deletions
|
@ -1,12 +1,10 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
|
||||
from symposion.conference.models import Section, current_conference, Conference
|
||||
from symposion.conference.models import Section, current_conference
|
||||
|
||||
from symposion.schedule.models import (Day, Presentation, Room, SlotKind, Schedule, Slot)
|
||||
|
||||
from symposion.schedule.models import Day, Schedule, Session
|
||||
|
||||
from symposion.schedule.models import (Day, Presentation, Room, SlotKind, Slot,
|
||||
SlotRoom, ProposalBase)
|
||||
from symposion.proposals.models import ProposalBase
|
||||
|
||||
from dateutil.parser import parse
|
||||
|
||||
|
@ -23,10 +21,6 @@ class Command(BaseCommand):
|
|||
help = "Updates the schedule based on two csv files, "\
|
||||
"one that gives all the talk slots, the other the talks."
|
||||
|
||||
def find_or_create_slot(self, date, start_time, end_time, room):
|
||||
print(date, start_time, end_time, room)
|
||||
return (date, start_time, end_time, room)
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(self.SLOTS, type=Path)
|
||||
parser.add_argument(self.TALKS, type=Path)
|
||||
|
@ -42,10 +36,6 @@ class Command(BaseCommand):
|
|||
section = Section.objects.filter(conference=conf, slug="main").all().first()
|
||||
schedule, _created = Schedule.objects.get_or_create(section=section)
|
||||
|
||||
print('conf', conf)
|
||||
print('section', section)
|
||||
print('schedule', schedule)
|
||||
|
||||
with open(options[self.SLOTS]) as csv_file:
|
||||
csv_reader = csv.reader(csv_file)
|
||||
|
||||
|
@ -78,7 +68,7 @@ class Command(BaseCommand):
|
|||
csv_reader = csv.reader(csv_file)
|
||||
|
||||
used_rooms = next(csv_reader)
|
||||
talk = {}
|
||||
talks = {}
|
||||
|
||||
assert used_rooms[0] == '', "Cell (1, 1) must be empty"
|
||||
|
||||
|
@ -99,7 +89,7 @@ class Command(BaseCommand):
|
|||
|
||||
assert (date, kindslot, room) in slot_details, f"Slot ({date}, '{kindslot}', '{room}') not found"
|
||||
|
||||
talk[(date, kindslot, room)] = int(talk_id)
|
||||
talks[(date, kindslot, room)] = int(talk_id)
|
||||
|
||||
else:
|
||||
assert parse(row[0]), "Not a date: {row[0]}"
|
||||
|
@ -111,13 +101,10 @@ class Command(BaseCommand):
|
|||
|
||||
days = {}
|
||||
for date in date_strs:
|
||||
print('schedule', type(schedule))
|
||||
day, _created = Day.objects.get_or_create(
|
||||
schedule=schedule, date=date)
|
||||
days[date] = day
|
||||
|
||||
print('days', days)
|
||||
|
||||
rooms = {}
|
||||
for room_name in room_names:
|
||||
room, _created = Room.objects.get_or_create(
|
||||
|
@ -128,6 +115,7 @@ 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]
|
||||
|
@ -143,3 +131,23 @@ class Command(BaseCommand):
|
|||
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
|
||||
kind_name = kindslot.rsplit(' ', 1)[0]
|
||||
|
||||
(start_time, end_time) = slot_details[(date, kindslot, room)]
|
||||
|
||||
slot = slots[(date, kind_name, start_time, end_time)]
|
||||
|
||||
proposal = ProposalBase.objects.filter(pk=talk_id).first()
|
||||
|
||||
assert proposal, f"Could not find proposal {talk_id}"
|
||||
|
||||
preso = Presentation.objects.filter(proposal_base=proposal).first()
|
||||
|
||||
print(f'would like to set {preso} to slot {slot}')
|
||||
|
||||
#preso.slot = slot
|
||||
preso.save()
|
||||
|
|
Loading…
Reference in a new issue