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

feat: add APIPlaylistViewSet

parent b3366088
No related branches found
No related tags found
1 merge request!59Add playlists
...@@ -54,6 +54,7 @@ from program.models import ( ...@@ -54,6 +54,7 @@ from program.models import (
LinkType, LinkType,
MusicFocus, MusicFocus,
Note, Note,
Playlist,
Profile, Profile,
RadioSettings, RadioSettings,
RRule, RRule,
...@@ -79,6 +80,7 @@ from program.serializers import ( ...@@ -79,6 +80,7 @@ from program.serializers import (
LinkTypeSerializer, LinkTypeSerializer,
MusicFocusSerializer, MusicFocusSerializer,
NoteSerializer, NoteSerializer,
PlaylistSerializer,
PlayoutProgramEntrySerializer, PlayoutProgramEntrySerializer,
ProfileSerializer, ProfileSerializer,
RadioSettingsSerializer, RadioSettingsSerializer,
...@@ -1630,3 +1632,26 @@ class APIApplicationStateView(TestOperationViewMixin, views.APIView): ...@@ -1630,3 +1632,26 @@ class APIApplicationStateView(TestOperationViewMixin, views.APIView):
invert_selection=params.validated_data["invert_selection"], invert_selection=params.validated_data["invert_selection"],
) )
return Response(status=status.HTTP_200_OK, data=deleted) return Response(status=status.HTTP_200_OK, data=deleted)
class APIPlaylistViewSet(viewsets.ModelViewSet):
serializer_class = PlaylistSerializer
def get_queryset(self):
"""The queryset is empty if the request is not authenticated, it contains all the playlists
if the request method is safe or if the requesting user has the `create_playlist` or the
`update_playlist`, otherwise it only contains playlists for shows owned by the
requesting user."""
user = self.request.user
if not user.is_authenticated:
return Playlist.objects.none()
elif (
self.request.method in permissions.SAFE_METHODS
or user.has_perm("program.create_playlist")
or user.has_perm("program.update_playlist")
):
return Playlist.objects.all()
else:
return Playlist.objects.filter(show__owners=user)
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