From e9dcccbced7043a2b3bfebf63b05142e50aba75d Mon Sep 17 00:00:00 2001 From: Alexander-D-Karpov Date: Sun, 7 Apr 2024 22:58:29 +0300 Subject: [PATCH] bug fixes --- akarpov/music/api/views.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/akarpov/music/api/views.py b/akarpov/music/api/views.py index 39bc162..7ec9af4 100644 --- a/akarpov/music/api/views.py +++ b/akarpov/music/api/views.py @@ -392,15 +392,14 @@ def get_queryset(self): def post(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=False) - data = serializer.validated_data try: - song = Song.objects.cache().get(slug=self.request.data.get("slug", "")) + song = Song.objects.cache().get(slug=self.request.data.get("song", "")) except Song.DoesNotExist: return Response(status=404) try: - user_id = data.get("user_id", None) + user_id = self.request.data.get("user_id", None) user = User.objects.get(id=user_id) if user != self.request.user: return Response(status=403) @@ -416,11 +415,11 @@ def post(self, request, *args, **kwargs): }, countdown=2, ) - elif "user_id" in data: + elif "user_id" in self.request.data: listen_to_song.apply_async( kwargs={ "song_id": song.id, - "user_id": data["user_id"], + "user_id": self.request.data.get("user_id", None), "anon": True, }, countdown=2,