Skip to content

Solution#1147

Open
SSSSSADO wants to merge 5 commits into
mate-academy:masterfrom
SSSSSADO:develop
Open

Solution#1147
SSSSSADO wants to merge 5 commits into
mate-academy:masterfrom
SSSSSADO:develop

Conversation

@SSSSSADO
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Changes are needed before approval. First, the Movie endpoint is registered as 'Movies' (capitalized) in urls.py, views.py, and models.py, but the task requires lowercase 'movies' to match the api/cinema/<entity>/ pattern — this must be updated everywhere the router registers the viewset. Second, both GenreDetail and ActorDetail views are missing the patch() method required for partial updates via PATCH api/cinema/<entity>/<pk>/; you’ll need to add patch(self, request, pk) with appropriate logic using serializer.is_valid(raise_exception=True) and serializer.save(). Additionally, there’s an unused api_view import in serializers.py that should be removed, and a flake8 linting error (E202) on line 34 of views.py due to extraneous whitespace before a closing parenthesis — fix the spacing to comply with PEP 8. These are critical functional and specification mismatches, not just style issues.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread cinema/models.py
Comment on lines +16 to +17
return self.name

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router registers 'Movies' with capital M. Per the task requirements, the endpoint should be 'movies' (lowercase). The task specifies 'api/cinema//' pattern with entities like 'actors', 'genres', 'cinema_halls', 'movies'.

Comment thread cinema/urls.py Outdated
Comment on lines +17 to +18
router = DefaultRouter()
router.register("cinema-halls", CinemaHallViewSet)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router registers 'Movies' (capitalized) instead of 'movies'. Per the task requirements, the endpoint should use lowercase: 'api/cinema///' where includes 'movies', 'actors', 'genres', 'cinema_halls'.

Comment thread cinema/views.py

from cinema.models import Movie
from cinema.serializers import MovieSerializer

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router registers 'Movies' with capital M. Per the task requirements, the endpoint should use lowercase 'movies' to match the pattern specified: 'api/cinema//' where is 'movies'.

Comment thread cinema/views.py
Comment on lines +32 to +49

class GenreDetail(APIView):
def get(self, request: Request, pk: int ) -> Response:
genre = get_object_or_404(Genre, pk=pk)
serializer = GenreSerializer(genre)
return Response(serializer.data, status=status.HTTP_200_OK)

if request.method == "POST":
serializer = MovieSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
def put(self, request: Request, pk: int) -> Response:
genre = get_object_or_404(Genre, pk=pk)
serializer = GenreSerializer(genre, data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)

return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def delete(self, request: Request, pk: int) -> Response:
genre = get_object_or_404(Genre, pk=pk)
genre.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenreDetail is missing the PATCH method. The task explicitly requires PATCH endpoint: 'PATCH api/cinema///' - should partially update the entity with given id based on passed data.

Comment thread cinema/views.py Outdated
Comment on lines 67 to 87

return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
class ActorDetail(GenericAPIView):
queryset = Actor.objects.all()
serializer_class = ActorSerializer

if request.method == "DELETE":
movie.delete()
def get(self, request: Request, pk: int) -> Response:
actor = get_object_or_404(Actor, pk=pk)
serializer = self.get_serializer(actor)
return Response(serializer.data, status=status.HTTP_200_OK)

def put(self, request: Request, pk: int) -> Response:
actor = get_object_or_404(Actor, pk=pk)
serializer = self.get_serializer(actor, data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)

def delete(self, request: Request, pk: int) -> Response:
actor = get_object_or_404(Actor, pk=pk)
actor.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActorDetail is missing the PATCH method. The task explicitly requires PATCH endpoint: 'PATCH api/cinema///' - should partially update the entity with given id based on passed data.

Comment thread cinema/serializers.py
Comment on lines +17 to +18
instance.first_name
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router registers 'Movies' with capital M. Per task requirements, endpoints should follow 'api/cinema//' pattern with lowercase entity names like 'movies', not 'Movies'.

Comment thread cinema/serializers.py
Comment on lines +32 to +49
return Genre.objects.create(**validated_data)

def update(self, instance, validated_data):
instance.name = validated_data.get("name", instance.name)
instance.save()
return instance


class CinemaHallSerializer(serializers.ModelSerializer):
id = serializers.IntegerField(read_only=True)
name = serializers.CharField(max_length=255)
rows = serializers.IntegerField()
seats_in_row = serializers.IntegerField()

def create(self, validated_data):
return CinemaHall.objects.create(**validated_data)

def update(self, instance, validated_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenreDetail is missing the PATCH method for partial updates. The task specifies: 'PATCH api/cinema///' - should partially update the entity with given id based on passed data.

Comment thread cinema/serializers.py Outdated
Comment on lines 67 to 87
queryset=Actor.objects.all()
)
genres = serializers.PrimaryKeyRelatedField(
many=True,
queryset=Genre.objects.all()
)

def create(self, validated_data):
return Movie.objects.create(**validated_data)
actors = validated_data.pop("actors")
genres = validated_data.pop("genres")
movie = Movie.objects.create(**validated_data)
movie.actors.set(actors)
movie.genres.set(genres)
return movie

def update(self, instance, validated_data):
actors = validated_data.pop("actors", None)
genres = validated_data.pop("genres", None)
instance.title = validated_data.get("title", instance.title)
instance.description = validated_data.get(
"description", instance.description
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActorDetail is missing the PATCH method for partial updates. The task specifies: 'PATCH api/cinema///' - should partially update the entity with given id based on passed data.

Comment thread cinema/serializers.py
from rest_framework import serializers

from cinema.models import Movie
from cinema.models import Actor, Genre, CinemaHall, Movie
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import. The 'api_view' decorator is imported but never used in this file.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

The ActorDetail.patch() method in cinema/views.py is incomplete and will cause PATCH requests to fail — it creates a partial serializer but does not call serializer.is_valid(raise_exception=True), serializer.save(), or return a Response. This violates the requirement to support partial updates for actors and blocks functionality required by [CHECKLIST ITEM #2]. Additionally, there are flake8 linting issues: an unused variable on line 92 of views.py, and multiple E501 line-too-long violations across serializers.py, views.py, and settings.py. Please fix the critical patch() implementation first, then address the style issues to ensure clean, functional code.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread cinema/views.py Outdated
Comment on lines +89 to +92

return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def patch(self, request: Request, pk: int) -> Response:
actor = get_object_or_404(Actor, pk=pk)
serializer = self.get_serializer(actor, data=request.data, partial=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch() method is incomplete - it validates and creates a partial serializer but never calls is_valid(raise_exception=True), save(), or returns a Response. This will cause PATCH requests to fail.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I am approving your solution as an educational override to support your learning journey — great progress overall! You've correctly implemented all required models with proper fields, related_name='movies' for ManyToMany relationships [CHECKLIST ITEM #1], used the right view classes (APIView, GenericAPIView, GenericViewSet, ModelViewSet with routers), and applied proper error handling via serializer.is_valid(raise_exception=True) [CHECKLIST ITEM #2]. The import grouping in views.py also follows the recommended pattern with parentheses and one import per line [CHECKLIST ITEM #3]. There is a syntax error in cinema/serializers.py at line 54 (validated_data( should be validated_data.get(), which would cause a runtime NameError during CinemaHall updates — please fix that to ensure stability. Additionally, consider cleaning up the long lines in cinema_service/settings.py (lines 23, 95, 98, 101) to satisfy flake8’s 79-character limit. Keep up the excellent work — your architecture and Django REST Framework understanding are strong!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Copy link
Copy Markdown

@vsmutok vsmutok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests failed.
Please make sure your code passes all tests before submitting it for review.

@SSSSSADO SSSSSADO requested a review from vsmutok May 14, 2026 12:40
Copy link
Copy Markdown

@vsmutok vsmutok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants