Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished #773

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Finished #773

wants to merge 12 commits into from

Conversation

Oleksa-32
Copy link

No description provided.

Copy link

@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.


Thank you for your hard work on this project! 😊 While you've made a great effort, there are a few critical issues that need to be addressed before we can approve the pull request.

  1. Incorrect Serializer Usage: In both the GenreList and GenreDetail classes, the MovieSerializer is used instead of the GenreSerializer. This needs to be corrected to ensure that the correct data is being serialized.

  2. Incorrect Model Reference: The get_object method in GenreDetail is incorrectly referencing the Movie model instead of the Genre model. This should be updated to use get_object_or_404(Genre, pk=pk).

  3. CinemaHallViewSet Serializer Class: The CinemaHallViewSet is incorrectly set with CinemaHall.objects.all() as the serializer_class. It should be set to CinemaHallSerializer.

  4. Create Method Issues: The create method in CinemaSerializer is incorrectly using Movie.objects.create, and the create method in GenreSerializer is incorrectly using Actor.objects.create. These should be corrected to use CinemaHall.objects.create and Genre.objects.create, respectively.

These issues are critical as they impact the core functionality of the application. Once these are resolved, your code will be in great shape! Keep up the good work, and don't hesitate to reach out if you need any help. 🚀

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

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

name = serializers.CharField(max_length=255)

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

Choose a reason for hiding this comment

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

The create method in GenreSerializer is incorrectly using Actor.objects.create. It should use Genre.objects.create to match the model being serialized.

seats_in_row = serializers.IntegerField()

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

Choose a reason for hiding this comment

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

The create method in CinemaSerializer is incorrectly using Movie.objects.create. It should use CinemaHall.objects.create to match the model being serialized.

cinema/urls.py Outdated
path("movies/<int:pk>/", movie_detail, name="movie-detail"),
path("", include(router.urls)),
path("genres/", GenreList.as_view(), name="genre-list"),
path("genres/<int:pk>", GenreDetail.as_view(), name="genre-detail"),

Choose a reason for hiding this comment

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

Consider adding a trailing slash to the genres/<int:pk> path for consistency with the other URL patterns.

cinema/urls.py Outdated
path("genres/", GenreList.as_view(), name="genre-list"),
path("genres/<int:pk>", GenreDetail.as_view(), name="genre-detail"),
path("actors/", ActorList.as_view(), name="actor-list"),
path("actors/<int:pk>", ActorDetail.as_view(), name="actor-detail"),

Choose a reason for hiding this comment

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

Consider adding a trailing slash to the actors/<int:pk> path for consistency with the other URL patterns.

cinema/views.py Outdated

def get(self, request):
genres = Genre.objects.all()
serializer = MovieSerializer(genres, many=True)

Choose a reason for hiding this comment

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

The GenreList class is using MovieSerializer instead of GenreSerializer for the get method. This should be corrected to GenreSerializer to match the model being serialized.

cinema/views.py Outdated
class GenreDetail(APIView):

def get_object(self, pk):
return get_object_or_404(Movie, pk=pk)

Choose a reason for hiding this comment

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

The get_object method in GenreDetail is incorrectly using Movie instead of Genre. It should be get_object_or_404(Genre, pk=pk) to match the context of the class.

cinema/views.py Outdated
serializer = MovieSerializer(movie)
def get(self, request, pk):
genre = self.get_object(pk)
serializer = MovieSerializer(genre)

Choose a reason for hiding this comment

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

The GenreDetail class is using MovieSerializer instead of GenreSerializer for the get method. This should be corrected to GenreSerializer to match the model being serialized.

cinema/views.py Outdated
viewsets.GenericViewSet
):
queryset = CinemaHall.objects.all()
serializer_class = CinemaHall.objects.all()

Choose a reason for hiding this comment

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

The CinemaHallViewSet is incorrectly assigning CinemaHall.objects.all() to serializer_class. It should be CinemaHallSerializer to correctly serialize the CinemaHall model.

Copy link

@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.

Great job on addressing the previous issues and refining your code! 🎉 Your migration file, models, and views are well-structured and meet the task requirements. However, there are a few areas to improve:

  • Redundancy in MovieSerializer: You've duplicated the lines updating title and description. Please remove these duplicates to enhance code quality and avoid redundancy.

Overall, your solution is solid and meets the task requirements. The decision to approve is to help you move forward with your learning journey. Please review the comments and address the mentioned issues to improve your code further. Keep up the good work and continue learning from these experiences! 🚀

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

Comment on lines +20 to +22
instance.title = validated_data.get("title", instance.title)
instance.description = validated_data.get("description",
instance.description)

Choose a reason for hiding this comment

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

The lines updating title and description are duplicated. Remove these lines to avoid redundancy, as they are already updated in lines 16-19.

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.

2 participants