Skip to content

Commit

Permalink
Fix flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Le0n-K committed Dec 9, 2024
1 parent eed67ff commit 6ffa392
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
3 changes: 2 additions & 1 deletion cinema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ class CinemaHall(models.Model):
seats_in_row = models.IntegerField()

def __str__(self):
return f"{self.name}, rows: {self.rows}, seats in row: {self.seats_in_row}"
return (f"{self.name}, rows: {self.rows},"
f"seats in row: {self.seats_in_row}")
12 changes: 9 additions & 3 deletions cinema/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ 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()
return instance

Expand Down Expand Up @@ -66,6 +70,8 @@ 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.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()
return instance
26 changes: 15 additions & 11 deletions cinema/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
router.register("movies", MovieViewSet)

cinema_hall_list = CinemaHallViewSet.as_view(
actions={
"get": "list",
"post": "create"
}
actions={
"get": "list",
"post": "create"
}
)
cinema_hall_detail = CinemaHallViewSet.as_view(
actions={
"get": "retrieve",
"put": "update",
"patch": "partial_update",
"delete": "destroy"
}
actions={
"get": "retrieve",
"put": "update",
"patch": "partial_update",
"delete": "destroy"
}
)
urlpatterns = [
path("", include(router.urls)),
Expand All @@ -34,7 +34,11 @@
path("genres/", GenreList.as_view(), name="genre-list"),
path("genres/<int:pk>/", GenreDetail.as_view(), name="genre-detail"),
path("cinema_halls/", cinema_hall_list, name="cinema-hall-list"),
path("cinema_halls/<int:pk>/", cinema_hall_detail, name="cinema-hall-detail")
path(
"cinema_halls/<int:pk>/",
cinema_hall_detail,
name="cinema-hall-detail"
)
]

app_name = "cinema"
7 changes: 6 additions & 1 deletion cinema/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from rest_framework.views import APIView

from cinema.models import Movie, Actor, CinemaHall, Genre
from cinema.serializers import MovieSerializer, ActorSerializer, CinemaHallSerializer, GenreSerializer
from cinema.serializers import (
MovieSerializer,
ActorSerializer,
CinemaHallSerializer,
GenreSerializer
)


class MovieViewSet(viewsets.ModelViewSet):
Expand Down

0 comments on commit 6ffa392

Please sign in to comment.