From cbfa3fc6948b062bbaf6629c823a45ff85c2af73 Mon Sep 17 00:00:00 2001 From: Vasyl Turok Date: Fri, 24 Nov 2023 23:50:41 +0200 Subject: [PATCH] Solution --- cinema/views.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cinema/views.py b/cinema/views.py index 686dd50a4..982579dcb 100644 --- a/cinema/views.py +++ b/cinema/views.py @@ -29,7 +29,7 @@ def post(self, request): serializer = GenreSerializer(data=request.data) if serializer.is_valid(): serializer.save() - return Response(serializer.data, status=status.HTTP_200_OK) + return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) @@ -54,12 +54,11 @@ def put(self, request, pk): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - def patch(self, request, pk) -> Response: + def patch(self, request, pk): genre = self.get_object(pk) serializer = GenreSerializer( genre, data=request.data, - partial=True ) serializer.is_valid(raise_exception=True) serializer.save() @@ -101,6 +100,13 @@ def get(self, request, *args, **kwargs): def put(self, request, *args, **kwargs): return self.update(request, *args, **kwargs) + def patch(self, request, *args, **kwargs) -> Response: + actor = self.get_object() + serializer = ActorSerializer(actor, data=request.data, partial=True) + serializer.is_valid(raise_exception=True) + serializer.save() + return Response(serializer.data, status=status.HTTP_200_OK) + def delete(self, request, *args, **kwargs): return self.destroy(request, *args, **kwargs) @@ -115,4 +121,3 @@ class CinemaHallViewSet( ): queryset = CinemaHall.objects.all() serializer_class = CinemaHallSerializer -