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

fix: update remaining APIs to camelCase notation

Closes #152
parent 432275d6
No related branches found
No related tags found
No related merge requests found
Pipeline #3455 passed
...@@ -92,40 +92,37 @@ logger = logging.getLogger(__name__) ...@@ -92,40 +92,37 @@ logger = logging.getLogger(__name__)
def timeslot_entry(*, timeslot: TimeSlot) -> dict: def timeslot_entry(*, timeslot: TimeSlot) -> dict:
"""return a timeslot entry as a dict""" """return a timeslot entry as a dict"""
show = timeslot.show
schedule = timeslot.schedule schedule = timeslot.schedule
show = timeslot.schedule.show
playlist_id = timeslot.playlist_id playlist_id = timeslot.playlist_id
title = show_name = f"{show.name} {_('REP')}" if schedule.is_repetition else show.name title = show_name = f"{show.name} {_('REP')}" if schedule.is_repetition else show.name
# we start and end as timezone naive datetime objects
start = timezone.make_naive(timeslot.start).strftime("%Y-%m-%dT%H:%M:%S")
end = timezone.make_naive(timeslot.end).strftime("%Y-%m-%dT%H:%M:%S")
return { return {
"end": end,
"id": timeslot.id, "id": timeslot.id,
# we need start & end as timezone naive datetime objects "playlistId": playlist_id,
"start": timezone.make_naive(timeslot.start).strftime("%Y-%m-%dT%H:%M:%S"),
"end": timezone.make_naive(timeslot.end).strftime("%Y-%m-%dT%H:%M:%S"),
"title": title,
"schedule_id": schedule.id,
# `Timeslot.repetition_of` is a foreign key that can be null # `Timeslot.repetition_of` is a foreign key that can be null
"is_repetition": timeslot.repetition_of.id if timeslot.repetition_of else False, "repetitionOfId": timeslot.repetition_of.id if timeslot.repetition_of else "",
"playlist_id": playlist_id, "scheduleDefaultPlaylistId": schedule.default_playlist_id,
"schedule_default_playlist_id": schedule.default_playlist_id, "scheduleId": schedule.id,
"show_default_playlist_id": show.default_playlist_id, "showCategories": ", ".join(show.category.values_list("name", flat=True)),
"show_id": show.id, "showDefaultPlaylistId": show.default_playlist_id,
"show_name": show_name,
"show_hosts": ", ".join(show.hosts.values_list("name", flat=True)),
# `Show.type` is a foreign key that can be null
"show_type": show.type.name if show.type_id else "",
"show_categories": ", ".join(show.category.values_list("name", flat=True)),
"show_topics": ", ".join(show.topic.values_list("name", flat=True)),
# TODO: replace `show_musicfocus` with `show_music_focus` when engine is updated
"show_musicfocus": ", ".join(show.music_focus.values_list("name", flat=True)),
"show_languages": ", ".join(show.language.values_list("name", flat=True)),
# TODO: replace `show_fundingcategory` with `show_funding_category` when engine is
# updated
# `Show.funding_category` is a foreign key can be null # `Show.funding_category` is a foreign key can be null
"show_fundingcategory": show.funding_category.name if show.funding_category_id else "", "showFundingCategory": show.funding_category.name if show.funding_category_id else "",
"memo": timeslot.memo, "showHosts": ", ".join(show.hosts.values_list("name", flat=True)),
"className": "danger" if playlist_id is None or playlist_id == 0 else "default", "showId": show.id,
"showLanguages": ", ".join(show.language.values_list("name", flat=True)),
"showMusicFocus": ", ".join(show.music_focus.values_list("name", flat=True)),
"showName": show_name,
"showTopics": ", ".join(show.topic.values_list("name", flat=True)),
# `Show.type` is a foreign key that can be null
"showType": show.type.name if show.type_id else "",
"start": start,
"title": title,
} }
...@@ -133,8 +130,8 @@ def gap_entry(*, gap_start: datetime, gap_end: datetime) -> dict: ...@@ -133,8 +130,8 @@ def gap_entry(*, gap_start: datetime, gap_end: datetime) -> dict:
"""return a virtual timeslot to fill the gap in between `gap_start` and `gap_end` as a dict""" """return a virtual timeslot to fill the gap in between `gap_start` and `gap_end` as a dict"""
return { return {
"start": gap_start.strftime("%Y-%m-%dT%H:%M:%S"),
"end": gap_end.strftime("%Y-%m-%dT%H:%M:%S"), "end": gap_end.strftime("%Y-%m-%dT%H:%M:%S"),
"start": gap_start.strftime("%Y-%m-%dT%H:%M:%S"),
"virtual": True, "virtual": True,
} }
...@@ -151,7 +148,6 @@ def json_day_schedule(request, year=None, month=None, day=None): ...@@ -151,7 +148,6 @@ def json_day_schedule(request, year=None, month=None, day=None):
timeslots = ( timeslots = (
TimeSlot.objects.get_timerange_timeslots(start, end) TimeSlot.objects.get_timerange_timeslots(start, end)
.select_related("schedule") .select_related("schedule")
.select_related("show")
) )
schedule = [] schedule = []
...@@ -203,12 +199,11 @@ def json_playout(request): ...@@ -203,12 +199,11 @@ def json_playout(request):
datetime.combine(parse_date(request.GET.get("end")) + timedelta(days=1), time(0, 0)) datetime.combine(parse_date(request.GET.get("end")) + timedelta(days=1), time(0, 0))
) )
include_virtual = request.GET.get("includeVirtual") == "true" include_virtual = request.GET.get("include_virtual") == "true"
timeslots = ( timeslots = (
TimeSlot.objects.get_timerange_timeslots(schedule_start, schedule_end) TimeSlot.objects.get_timerange_timeslots(schedule_start, schedule_end)
.select_related("schedule") .select_related("schedule")
.select_related("show")
) )
schedule = [] schedule = []
......
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