Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
VasylTurok committed Nov 24, 2023
1 parent ac9bb92 commit cbfa3fc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cinema/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
Expand Down Expand Up @@ -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)

Expand All @@ -115,4 +121,3 @@ class CinemaHallViewSet(
):
queryset = CinemaHall.objects.all()
serializer_class = CinemaHallSerializer

0 comments on commit cbfa3fc

Please sign in to comment.