Skip to content
Snippets Groups Projects
Verified Commit 03020542 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: simplify code to get optional data

parent aade334f
No related branches found
No related tags found
No related merge requests found
......@@ -176,8 +176,6 @@ def resolve_conflicts(data: ScheduleCreateUpdateData, schedule_pk: int | None, s
errors[timeslot["hash"]] = _("Given solution is not accepted for this conflict.")
continue
"""Conflict resolution"""
existing = timeslot["collisions"][0]
solution = solutions[timeslot["hash"]]
......@@ -374,24 +372,22 @@ def instantiate_upcoming_schedule(
rrule = RRule.objects.get(pk=data["rrule_id"])
show = Show.objects.get(pk=show_pk)
is_repetition = data["is_repetition"] if "is_repetition" in data else False
is_repetition = data.get("is_repetition", False)
# default is `False`
add_business_days_only = (
data["add_business_days_only"] if "add_business_days_only" in data else False
)
add_business_days_only = data.get("add_business_days_only", False)
# default is `None`
add_days_no = data.get("add_days_no")
by_weekday = data.get("by_weekday")
default_playlist_id = data.get("default_playlist_id")
# required
first_date = parse_date(data["first_date"])
start_time = parse_time(data["start_time"])
end_time = parse_time(data["end_time"])
# last_date may not be present in data
last_date = parse_date(data["last_date"]) if data.get("last_date") is not None else None
# last_date may not be present in data, parse_date returns `None` in this case
last_date = parse_date(data.get("last_date"))
return Schedule(
pk=pk,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment