mirror of
https://github.com/Alexander-D-Karpov/akarpov
synced 2024-11-22 01:36:33 +03:00
bug fixes
This commit is contained in:
parent
06afed5882
commit
e9dcccbced
|
@ -392,15 +392,14 @@ def get_queryset(self):
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
serializer = self.get_serializer(data=request.data)
|
serializer = self.get_serializer(data=request.data)
|
||||||
serializer.is_valid(raise_exception=False)
|
serializer.is_valid(raise_exception=False)
|
||||||
data = serializer.validated_data
|
|
||||||
|
|
||||||
try:
|
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:
|
except Song.DoesNotExist:
|
||||||
return Response(status=404)
|
return Response(status=404)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_id = data.get("user_id", None)
|
user_id = self.request.data.get("user_id", None)
|
||||||
user = User.objects.get(id=user_id)
|
user = User.objects.get(id=user_id)
|
||||||
if user != self.request.user:
|
if user != self.request.user:
|
||||||
return Response(status=403)
|
return Response(status=403)
|
||||||
|
@ -416,11 +415,11 @@ def post(self, request, *args, **kwargs):
|
||||||
},
|
},
|
||||||
countdown=2,
|
countdown=2,
|
||||||
)
|
)
|
||||||
elif "user_id" in data:
|
elif "user_id" in self.request.data:
|
||||||
listen_to_song.apply_async(
|
listen_to_song.apply_async(
|
||||||
kwargs={
|
kwargs={
|
||||||
"song_id": song.id,
|
"song_id": song.id,
|
||||||
"user_id": data["user_id"],
|
"user_id": self.request.data.get("user_id", None),
|
||||||
"anon": True,
|
"anon": True,
|
||||||
},
|
},
|
||||||
countdown=2,
|
countdown=2,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user