Skip to content

Commit

Permalink
Removed redundant if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
OstapIvakh committed Oct 20, 2023
1 parent 277d2c9 commit 0b30d77
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cinema/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def get(self, request):
def post(self, request):
serializer = GenreSerializer(data=request.data)

if serializer.is_valid(raise_exception=True):
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)


class GenreDetail(APIView):
Expand All @@ -40,16 +40,18 @@ def get(self, request, pk):
def put(self, request, pk):
genre = self.get_object(pk)
serializer = GenreSerializer(genre, data=request.data)
if serializer.is_valid(raise_exception=True):
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)

serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)

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

serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)

def delete(self, request, pk):
genre = self.get_object(pk)
Expand Down

0 comments on commit 0b30d77

Please sign in to comment.