Skip to content

Commit

Permalink
flake
Browse files Browse the repository at this point in the history
  • Loading branch information
VolodymyrSemchysyn committed Dec 11, 2024
1 parent 7f236d7 commit 8c8adfa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
10 changes: 6 additions & 4 deletions cinema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ def clean(self):
(self.row, "row", "count_rows"),
(self.seat, "seat", "count_seats_in_row"),
]:
count_attrs = getattr(self.movie_session.cinema_hall, cinema_hall_attr_name)
count_attrs = getattr(
self.movie_session.cinema_hall, cinema_hall_attr_name
)
if not (1 <= ticket_attr_value <= count_attrs):
raise ValidationError(
{
ticket_attr_name: f"{ticket_attr_name} number "
f"must be in available range: "
f"(1, {cinema_hall_attr_name}): "
f"(1, {count_attrs})"
f"must be in available range: "
f"(1, {cinema_hall_attr_name}): "
f"(1, {count_attrs})"
}
)

Expand Down
5 changes: 4 additions & 1 deletion cinema/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class MovieDetailSerializer(MovieSerializer):

class MovieSessionSerializer(serializers.ModelSerializer):
movie = serializers.PrimaryKeyRelatedField(queryset=Movie.objects.all())
cinema_hall = serializers.PrimaryKeyRelatedField(queryset=CinemaHall.objects.all())
cinema_hall = (serializers.
PrimaryKeyRelatedField
(queryset=CinemaHall.objects.all()))

class Meta:
model = MovieSession
fields = ("show_time", "movie", "cinema_hall")
Expand Down
8 changes: 6 additions & 2 deletions cinema/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
router.register("genres", GenreViewSet)
router.register("actors", ActorViewSet)
router.register("movies", MovieViewSet, basename="movie")
router.register("movie_sessions", MovieSessionViewSet, basename="movie_session")
router.register(
"movie_sessions",
MovieSessionViewSet,
basename="movie_session"
)

urlpatterns = [
path("", include(router.urls))
]

app_name = "cinema"
app_name = "cinema"

0 comments on commit 8c8adfa

Please sign in to comment.