From 9385d07eb023e3eea25dad31ac6355957dddb0d6 Mon Sep 17 00:00:00 2001 From: Oksana Boliziuk Date: Mon, 6 Jan 2025 19:41:24 +0200 Subject: [PATCH] Fix validate_seat_and_row error handling, update action comparison in views, and add pagination settings --- cinema/models.py | 2 +- cinema/serializers.py | 1 + cinema/views.py | 2 +- cinema_service/settings.py | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cinema/models.py b/cinema/models.py index f3f10620..07ee7f7a 100644 --- a/cinema/models.py +++ b/cinema/models.py @@ -89,7 +89,7 @@ def validate_seat_and_row( row: int, seat: int, movie_session, - error_to_raise + error_to_raise=ValidationError ): cinema_hall = movie_session.cinema_hall diff --git a/cinema/serializers.py b/cinema/serializers.py index 6ca5ffef..a5774dfe 100644 --- a/cinema/serializers.py +++ b/cinema/serializers.py @@ -131,6 +131,7 @@ def validate(self, attrs): return data + class TicketDetailSerializer(serializers.ModelSerializer): movie_session = MovieSessionListSerializer(read_only=True) diff --git a/cinema/views.py b/cinema/views.py index 3d749655..61bc6bdc 100644 --- a/cinema/views.py +++ b/cinema/views.py @@ -56,7 +56,7 @@ def get_queryset(self): if title: queryset = queryset.filter(title__icontains=title) - if self.action == ("list", "retrieve"): + if self.action == ["list", "retrieve"]: queryset = Movie.objects.prefetch_related("actors") return queryset.distinct() diff --git a/cinema_service/settings.py b/cinema_service/settings.py index 1c07e969..3f3ee32a 100644 --- a/cinema_service/settings.py +++ b/cinema_service/settings.py @@ -128,6 +128,11 @@ # USE_TZ = False +# REST_FRAMEWORK = { +# "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination", +# "PAGE_SIZE": 1 +# } + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.0/howto/static-files/