update metadata only, on API call

This commit is contained in:
Markos Gogoulos 2024-09-20 19:26:13 +03:00
parent d665058b80
commit 94c646fdb8

View File

@ -598,14 +598,15 @@ class MediaDetail(APIView):
media = self.get_object(friendly_token)
if isinstance(media, Response):
return media
serializer = MediaSerializer(media, data=request.data, context={"request": request})
if serializer.is_valid():
if request.data.get('media_file'):
media_file = request.data["media_file"]
serializer.save(user=request.user, media_file=media_file)
else:
serializer.save(user=request.user)
serializer.save(user=request.user)
# no need to update the media file itself, only the metadata
#if request.data.get('media_file'):
# media_file = request.data["media_file"]
# serializer.save(user=request.user, media_file=media_file)
#else:
# serializer.save(user=request.user)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)