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

feat: simplify get_queryset

parent 1284fc65
No related branches found
No related tags found
1 merge request!59Add playlists
......@@ -1638,20 +1638,12 @@ 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."""
"""The queryset is empty if the request is not authenticated. Otherwise, it contains all
the playlists."""
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)
return Playlist.objects.all()
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