From 151c0d11148ddf1c9b49e9c5d887561b71b7a624 Mon Sep 17 00:00:00 2001 From: Tsvetan Kichuk Date: Sat, 28 Sep 2024 13:30:24 +0200 Subject: [PATCH] 'Solution' --- cinema/serializers.py | 19 +++++++++++++------ cinema/urls.py | 5 ++--- cinema/views.py | 8 +++----- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/cinema/serializers.py b/cinema/serializers.py index 53462cc7f..97cae25c1 100644 --- a/cinema/serializers.py +++ b/cinema/serializers.py @@ -15,7 +15,8 @@ def create(self, validated_data): def update(self, instance, validated_data): instance.title = validated_data.get("title", instance.title) instance.description = validated_data.get( - "description", instance.description + "description", + instance.description ) instance.duration = validated_data.get("duration", instance.duration) @@ -35,10 +36,10 @@ def create(self, validated_data): def update(self, instance, validated_data): instance.name = validated_data.get("name", instance.name) - instance.rows = validated_data.get( - "rows", instance.rows + instance.rows = validated_data.get("rows", instance.rows) + instance.seats_in_row = validated_data.get( + "seats_in_row", instance.seats_in_row ) - instance.seats_in_row = validated_data.get("seats_in_row", instance.seats_in_row) instance.save() @@ -67,8 +68,14 @@ def create(self, validated_data): return Actor.objects.create(**validated_data) def update(self, instance, validated_data): - instance.first_name = validated_data.get("first_name", instance.first_name) - instance.last_name = validated_data.get("last_name", instance.last_name) + instance.first_name = validated_data.get( + "first_name", + instance.first_name + ) + instance.last_name = validated_data.get( + "last_name", + instance.last_name + ) instance.save() diff --git a/cinema/urls.py b/cinema/urls.py index cfd080ec1..1d74b5776 100644 --- a/cinema/urls.py +++ b/cinema/urls.py @@ -7,7 +7,7 @@ ActorList, ActorDetail, GenreList, - GenreDetail + GenreDetail, ) router = routers.DefaultRouter() @@ -20,6 +20,5 @@ path("genres//", GenreDetail.as_view(), name="genre-detail"), path("actors/", ActorList.as_view(), name="actor-list"), path("actors//", ActorDetail.as_view(), name="actor-detail"), - ] - +] app_name = "cinema" diff --git a/cinema/views.py b/cinema/views.py index 171193e08..8d5b9971c 100644 --- a/cinema/views.py +++ b/cinema/views.py @@ -50,9 +50,7 @@ def delete(self, request, pk): class ActorList( - mixins.ListModelMixin, - mixins.CreateModelMixin, - generics.GenericAPIView + mixins.ListModelMixin, mixins.CreateModelMixin, generics.GenericAPIView ): queryset = Actor.objects.all() serializer_class = ActorSerializer @@ -68,7 +66,7 @@ class ActorDetail( mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, - generics.GenericAPIView + generics.GenericAPIView, ): queryset = Actor.objects.all() @@ -90,7 +88,7 @@ class CinemaHallViewSet( mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, - viewsets.GenericViewSet + viewsets.GenericViewSet, ): queryset = CinemaHall.objects.all()