refactor: enhance response formatting in

FileUploadView

Improved the readability and maintainability of the response formatting
in `FileUploadView` by restructuring the return statement for a clearer
separation of its components. Additionally, ensured consistent file
formatting practices across user views, maintaining a clean and
standardized codebase. These changes aim to facilitate future debugging
and enhancements by making the code more accessible and easier to
understand.
This commit is contained in:
Kumi 2024-03-27 07:57:00 +01:00
parent c9e9e99728
commit 587bab9c64
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -91,14 +91,19 @@ class FileUploadView(LoginRequiredMixin, GenericAPIView):
instance = serializer.save()
instance.category = Category.objects.get(id=kwargs["category"])
instance.save()
return Response(OriginalMediaSerializer(instance, context={'request': request}).data, status=status.HTTP_201_CREATED)
return Response(
OriginalMediaSerializer(instance, context={"request": request}).data,
status=status.HTTP_201_CREATED,
)
else:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
class Login(TitleMixin, LoginView):
title = "Login"
template_name = "users/login.html"
class Logout(LogoutView):
pass
pass