Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Stekloduv committed Oct 29, 2024
1 parent 26b27df commit 3072600
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
11 changes: 4 additions & 7 deletions cinema/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
GenreAPIView,
ActorListCreateAPIView,
ActorRetrieveUpdateDestroyAPIView,
CinemaHallViewSet,
MovieViewSet
MovieViewSet, ActorList, GenreList, ActorDetail
)

app_name = "cinema"
Expand All @@ -26,17 +23,17 @@
urlpatterns = [
path(
"genres/",
GenreAPIView.as_view(),
GenreList.as_view(),
name="genre-list"
),
path(
"actors/",
ActorListCreateAPIView.as_view(),
ActorList.as_view(),
name="actor-list-create"
),
path(
"actors/<int:pk>/",
ActorRetrieveUpdateDestroyAPIView.as_view(),
ActorDetail.as_view(),
name="actor-detail"
),
path(
Expand Down
10 changes: 4 additions & 6 deletions cinema/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from rest_framework.decorators import api_view
from rest_framework.generics import (
ListCreateAPIView,
RetrieveUpdateDestroyAPIView
)
from rest_framework.response import Response
from rest_framework import status, viewsets, generics
from rest_framework import status, viewsets

from django.shortcuts import get_object_or_404
from rest_framework.views import APIView

from cinema.models import Movie, Genre, Actor, CinemaHall
Expand All @@ -23,7 +21,7 @@ class MovieViewSet(viewsets.ModelViewSet):
serializer_class = MovieSerializer


class GenreAPIView(APIView):
class GenreList(APIView):
def get(self, request):
genres = Genre.objects.all()
serializer = GenreSerializer(genres, many=True)
Expand All @@ -43,12 +41,12 @@ def post(self, request):
)


class ActorListCreateAPIView(ListCreateAPIView):
class ActorList(ListCreateAPIView):
queryset = Actor.objects.all()
serializer_class = ActorSerializer


class ActorRetrieveUpdateDestroyAPIView(RetrieveUpdateDestroyAPIView):
class ActorDetail(RetrieveUpdateDestroyAPIView):
queryset = Actor.objects.all()
serializer_class = ActorSerializer

Expand Down

0 comments on commit 3072600

Please sign in to comment.