From 9b43cd667489b8470e55e4a5dc26e491b1ac4843 Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Fri, 13 Oct 2023 16:37:08 -0400 Subject: [PATCH] fix: remove remaining references to show Timeslot --- program/services.py | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/program/services.py b/program/services.py index 0827568e..b5da2bc2 100644 --- a/program/services.py +++ b/program/services.py @@ -147,9 +147,7 @@ def resolve_conflicts(data: ScheduleCreateUpdateData, schedule_pk: int | None, s # If no solution necessary: Create the projected timeslot and skip if "solution_choices" not in timeslot or len(timeslot["collisions"]) == 0: to_create.append( - TimeSlot.objects.instantiate( - timeslot["start"], timeslot["end"], new_schedule - ), + TimeSlot.objects.instantiate(timeslot["start"], timeslot["end"], new_schedule), ) continue @@ -182,9 +180,7 @@ def resolve_conflicts(data: ScheduleCreateUpdateData, schedule_pk: int | None, s # - Create the projected timeslot # - Delete the existing collision(s) to_create.append( - TimeSlot.objects.instantiate( - timeslot["start"], timeslot["end"], new_schedule, show - ), + TimeSlot.objects.instantiate(timeslot["start"], timeslot["end"], new_schedule), ) # Delete collision(s) @@ -198,18 +194,14 @@ def resolve_conflicts(data: ScheduleCreateUpdateData, schedule_pk: int | None, s # - Keep the existing timeslot # - Create projected with end of existing start to_create.append( - TimeSlot.objects.instantiate( - timeslot["start"], existing["start"], new_schedule, show - ), + TimeSlot.objects.instantiate(timeslot["start"], existing["start"], new_schedule), ) if solution == "ours-end": # - Create the projected timeslot # - Change the start of the existing collision to projected end to_create.append( - TimeSlot.objects.instantiate( - timeslot["start"], timeslot["end"], new_schedule, show - ), + TimeSlot.objects.instantiate(timeslot["start"], timeslot["end"], new_schedule), ) existing_ts = TimeSlot.objects.get(pk=existing["timeslot_id"]) @@ -220,16 +212,14 @@ def resolve_conflicts(data: ScheduleCreateUpdateData, schedule_pk: int | None, s # - Keep existing # - Create projected with start time of existing end to_create.append( - TimeSlot.objects.instantiate(existing["end"], timeslot["end"], new_schedule, show), + TimeSlot.objects.instantiate(existing["end"], timeslot["end"], new_schedule), ) if solution == "ours-start": # - Create the projected timeslot # - Change end of existing to projected start to_create.append( - TimeSlot.objects.instantiate( - timeslot["start"], timeslot["end"], new_schedule, show - ), + TimeSlot.objects.instantiate(timeslot["start"], timeslot["end"], new_schedule), ) existing_ts = TimeSlot.objects.get(pk=existing["timeslot_id"]) @@ -240,13 +230,11 @@ def resolve_conflicts(data: ScheduleCreateUpdateData, schedule_pk: int | None, s # - Keep existing # - Create two projected timeslots with end of existing start and start of existing end to_create.append( - TimeSlot.objects.instantiate( - timeslot["start"], existing["start"], new_schedule, show - ), + TimeSlot.objects.instantiate(timeslot["start"], existing["start"], new_schedule), ) to_create.append( - TimeSlot.objects.instantiate(existing["end"], timeslot["end"], new_schedule, show), + TimeSlot.objects.instantiate(existing["end"], timeslot["end"], new_schedule), ) if solution == "ours-both": @@ -255,9 +243,7 @@ def resolve_conflicts(data: ScheduleCreateUpdateData, schedule_pk: int | None, s # - Set existing end time to projected start # - Create another one with start = projected end and end = existing end to_create.append( - TimeSlot.objects.instantiate( - timeslot["start"], timeslot["end"], new_schedule, show - ), + TimeSlot.objects.instantiate(timeslot["start"], timeslot["end"], new_schedule), ) existing_ts = TimeSlot.objects.get(pk=existing["timeslot_id"]) @@ -265,7 +251,7 @@ def resolve_conflicts(data: ScheduleCreateUpdateData, schedule_pk: int | None, s to_update.append(existing_ts) to_create.append( - TimeSlot.objects.instantiate(timeslot["end"], existing["end"], new_schedule, show), + TimeSlot.objects.instantiate(timeslot["end"], existing["end"], new_schedule), ) # If there were any errors, don't make any db changes yet @@ -641,8 +627,8 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: "start": str(c.start), "end": str(c.end), "playlist_id": c.playlist_id, - "show_id": c.show.id, - "show_name": c.show.name, + "show_id": c.schedule.show.id, + "show_name": c.schedule.show.name, "schedule_id": c.schedule_id, "memo": c.memo, } -- GitLab