Skip to content

Commit

Permalink
Finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksa-32 committed Jan 5, 2025
1 parent 75e4d14 commit 574032d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cinema/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ def put(self, request, pk):
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


def patch(self, request, pk):
genre = self.get_object(pk)
serializer = GenreSerializer(genre, data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

def delete(self, request, pk):
genre = self.get_object(pk)
genre.delete()
Expand Down Expand Up @@ -79,6 +88,9 @@ def get(self, request, *args, **kwargs):
def put(self, request, *args, **kwargs):
return self.update(request, *args, **kwargs)

def patch(self, request, *args, **kwargs):
return self.partial_update(request, *args, **kwargs)

def delete(self, request, *args, **kwargs):
return self.destroy(request, *args, **kwargs)

Expand Down

0 comments on commit 574032d

Please sign in to comment.