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

Complete project with serializers and views(API, Generic and ViewSet) #771

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

Conversation

sind14
Copy link

@sind14 sind14 commented Dec 22, 2024

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.

Your work is almost there! 🎉 However, there are a couple of critical issues that need addressing before we can approve the PR. The putch typo in the GenreDetail class is crucial as it affects the functionality of handling PATCH requests. Additionally, defining related_name for the ManyToManyField in the Movie model is required to meet the task requirements. Once these are fixed, your implementation will be in great shape! Keep up the good work! 😊

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

@@ -1,6 +1,5 @@
from rest_framework import serializers

from cinema.models import Movie
from cinema.models import Movie, Actor, Genre, CinemaHall


class MovieSerializer(serializers.Serializer):

Choose a reason for hiding this comment

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

Consider using serializers.ModelSerializer instead of serializers.Serializer for MovieSerializer. This will simplify the code by automatically generating fields and methods based on the Movie model.

@@ -22,3 +21,60 @@
instance.save()

return instance


class ActorSerializer(serializers.Serializer):

Choose a reason for hiding this comment

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

Consider using serializers.ModelSerializer for ActorSerializer to automatically handle fields and methods based on the Actor model.

return instance


class GenreSerializer(serializers.Serializer):

Choose a reason for hiding this comment

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

Consider using serializers.ModelSerializer for GenreSerializer to simplify the code by leveraging the Genre model.

return instance


class CinemaHallSerializer(serializers.Serializer):

Choose a reason for hiding this comment

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

Consider using serializers.ModelSerializer for CinemaHallSerializer to automatically handle fields and methods based on the CinemaHall model.

cinema/views.py Outdated
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

if request.method == "DELETE":
movie.delete()
def putch(self, request, pk):

Choose a reason for hiding this comment

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

There is a typo in the method name putch. It should be patch to correctly handle HTTP PATCH requests for partial updates.

Anton Hryhorenko added 2 commits December 22, 2024 19:29
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.

Review Summary

Great progress on the implementation! 🎉 The code is mostly aligned with the task requirements, and you've addressed several previous issues effectively. Here are some key points to consider for improvement:

  1. related_name for ManyToManyField: The Movie model is missing the related_name attribute for its ManyToManyField fields (actors and genres). Adding this attribute is crucial for enabling reverse querying from the Actor and Genre models, as specified in the task checklist.

  2. Typo Correction: The typo in the GenreDetail class has been corrected, which is a positive step forward. The method is now correctly named patch, aligning with standard HTTP methods.

  3. General Code Quality: The serializers, URL routing, and view implementations are well-structured and meet the task requirements. Keep up the good work in maintaining clean and efficient code.

While the decision is to APPROVE this pull request to help you move forward with your learning, please ensure to address the missing related_name attributes in future updates. This will enhance the functionality and maintainability of your code. Keep learning and improving! 🚀

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

migrations.AddField(
model_name='movie',
name='actors',
field=models.ManyToManyField(to='cinema.actor'),

Choose a reason for hiding this comment

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

The ManyToManyField for actors in the Movie model should include a related_name attribute as per the task requirements. This allows for reverse querying from the Actor model.

migrations.AddField(
model_name='movie',
name='genres',
field=models.ManyToManyField(to='cinema.genre'),

Choose a reason for hiding this comment

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

The ManyToManyField for genres in the Movie model should include a related_name attribute as per the task requirements. This allows for reverse querying from the Genre model.

class Movie(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
duration = models.IntegerField()
actors = models.ManyToManyField(Actor)

Choose a reason for hiding this comment

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

The ManyToManyField for actors in the Movie model should include a related_name attribute as per the task requirements. This allows for reverse querying from the Actor model.

class Movie(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
duration = models.IntegerField()
actors = models.ManyToManyField(Actor)
genres = models.ManyToManyField(Genre)

Choose a reason for hiding this comment

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

The ManyToManyField for genres in the Movie model should include a related_name attribute as per the task requirements. This allows for reverse querying from the Genre model.

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