diff --git a/program/views.py b/program/views.py index 22cb078908a11b6b696b6aca58979189373d0e4b..ddf8b45cd5835e01b3eee08808bdde8833c9a01a 100644 --- a/program/views.py +++ b/program/views.py @@ -40,6 +40,7 @@ from program.utils import get_cached_shows logger = logging.getLogger(__name__) + def json_day_schedule(request, year=None, month=None, day=None): if year is None and month is None and day is None: today = datetime.combine(date.today(), time(0, 0)) @@ -258,8 +259,13 @@ class APIShowViewSet(viewsets.ModelViewSet): /shows/?active=false returns all inactive shows (= past or upcoming) (GET) /shows/?public=true returns all public shows (GET) /shows/?public=false returns all non-public shows (GET) - /shows/?host={host} returns shows assigned to a given host (GET) - /shows/?owner={owner} returns shows of a given owner (GET) + /shows/?host={host_pk} returns shows assigned to a given host (GET) + /shows/?owner={owner_pk} returns shows of a given owner (GET) + /shows/?language={language_pk} returns shows in a given language (GET) + /shows/?type={type_pk} returns shows of a given type (GET) + /shows/?category={category_pk} returns shows of a given category (GET) + /shows/?topic={topic_pk} returns shows of a given topic (GET) + /shows/?musicfocus={musicfocus_pk} returns shows of a given music focus (GET) /shows/{pk} retrieves or updates (if owned) a single show (GET, PUT). Only superusers may add and delete shows @@ -311,6 +317,18 @@ class APIShowViewSet(viewsets.ModelViewSet): # Filter shows by host shows = shows.filter(hosts__in=[int(host)]) + if language := self.request.query_params.get('language'): + shows = shows.filter(language__in=[int(language)]) + + if type_ := self.request.query_params.get('type'): + shows = shows.filter(type__in=[int(type_)]) + + if topic := self.request.query_params.get('topic'): + shows = shows.filter(topic__in=[int(topic)]) + + if musicfocus := self.request.query_params.get('musicfocus'): + shows = shows.filter(musicfocus__in=[int(musicfocus)]) + return shows def create(self, request, *args, **kwargs): @@ -594,7 +612,6 @@ class APITimeSlotViewSet(viewsets.ModelViewSet): pk = int_or_none('pk', self.kwargs) show_pk = int_or_none('show_pk', self.kwargs) - if show_pk: timeslot = get_object_or_404(TimeSlot, pk=pk, show=show_pk) else: