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

Solution #734

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

Solution #734

wants to merge 5 commits into from

Conversation

Bondzik-S
Copy link

No description provided.

Copy link

@MatvijSafonov MatvijSafonov left a comment

Choose a reason for hiding this comment

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

Gj !

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 pull request! 😊 While your code is mostly well-structured and aligns with Django and Django REST Framework best practices, there is a critical issue that needs to be addressed before we can approve it.

The condition self.action == ("list", "retrieve") is incorrect and affects the functionality of your viewsets. It should be self.action in ("list", "retrieve") to properly check if the action is either 'list' or 'retrieve'. This change is crucial for ensuring that your custom querysets and serializers are applied correctly based on the action.

Once you make this adjustment, your code should be ready for approval. Keep up the great work, and don't hesitate to reach out if you have any questions! 🚀

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

cinema/views.py Outdated
@@ -34,6 +39,28 @@ class MovieViewSet(viewsets.ModelViewSet):
queryset = Movie.objects.all()
serializer_class = MovieSerializer

def get_queryset(self):
queryset = super().get_queryset()
if self.action == ("list", "retrieve"):

Choose a reason for hiding this comment

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

The condition self.action == ("list", "retrieve") is incorrect. It should be self.action in ("list", "retrieve") to check if the action is either 'list' or 'retrieve'.

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 implementing the task requirements! 🎉 Your code is well-structured and adheres to Django and Django REST Framework best practices. The unique constraints and validations are correctly implemented, and the endpoints function as expected.

However, there are a couple of minor improvements you can make:

  • Redundant select_related Call: In MovieSessionViewSet, the select_related call for 'movie' and 'cinema_hall' is already handled in the 'retrieve' action. Consider removing this redundant call within the 'list' and 'retrieve' check to avoid unnecessary repetition.
  • Redundant read_only_fields: In TicketInfoSeatsSerializer, the read_only_fields attribute is unnecessary since all fields are already read-only by default. Removing this line can help clean up the code.

These issues are not critical, but addressing them will improve your code quality. Keep up the great work, and continue learning from these experiences! 🚀

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

class Meta:
model = Ticket
fields = ("row", "seat")
read_only_fields = fields

Choose a reason for hiding this comment

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

The read_only_fields attribute is redundant here because all fields in TicketInfoSeatsSerializer are already marked as read-only by default. You can remove this line to clean up the code.

Comment on lines +109 to +110
if self.action in ("list", "retrieve"):
queryset = queryset.select_related("movie", "cinema_hall")

Choose a reason for hiding this comment

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

The select_related call for 'movie' and 'cinema_hall' is already handled in the 'retrieve' action. You can remove this redundant call within the 'list' and 'retrieve' check to avoid unnecessary repetition.

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