fix: don't try to save owner
This commit is contained in:
parent
d7269106db
commit
461abd2e46
@ -16,6 +16,7 @@ from .serializers import (
|
|||||||
from fellchensammlung.models import Animal, RescueOrganization, AdoptionNotice, Species, Image
|
from fellchensammlung.models import Animal, RescueOrganization, AdoptionNotice, Species, Image
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
|
|
||||||
|
|
||||||
class AdoptionNoticeApiView(APIView):
|
class AdoptionNoticeApiView(APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
@ -84,7 +85,6 @@ class AdoptionNoticeApiView(APIView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AnimalApiView(APIView):
|
class AnimalApiView(APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
@ -118,6 +118,7 @@ class AnimalApiView(APIView):
|
|||||||
)
|
)
|
||||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
class RescueOrganizationApiView(APIView):
|
class RescueOrganizationApiView(APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
@ -159,13 +160,14 @@ class RescueOrganizationApiView(APIView):
|
|||||||
"""
|
"""
|
||||||
serializer = RescueOrgSerializer(data=request.data, context={"request": request})
|
serializer = RescueOrgSerializer(data=request.data, context={"request": request})
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
rescue_org = serializer.save(owner=request.user)
|
rescue_org = serializer.save()
|
||||||
return Response(
|
return Response(
|
||||||
{"message": "Rescue organization created/updated successfully!", "id": rescue_org.id},
|
{"message": "Rescue organization created/updated successfully!", "id": rescue_org.id},
|
||||||
status=status.HTTP_201_CREATED,
|
status=status.HTTP_201_CREATED,
|
||||||
)
|
)
|
||||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
class AddImageApiView(APIView):
|
class AddImageApiView(APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user