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 #742

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

Solution #742

wants to merge 2 commits into from

Conversation

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

Great job on implementing the core functionality and meeting most of the task requirements! 🎉 While there are a few areas for improvement, such as refining validation methods and enhancing error handling, these are minor and don't significantly impact the functionality. Keep up the good work, and consider the feedback for future enhancements! 😊

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

row: int,
seat: int,
movie_session: MovieSession,
error_to_raise

Choose a reason for hiding this comment

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

The parameter error_to_raise is unconventional for a validation method. Typically, validation methods directly raise ValidationError without passing an error class as a parameter. Consider removing this parameter and directly raising ValidationError.

Comment on lines +118 to +119
except ValidationError as e:
raise ValidationError(e.message_dict)

Choose a reason for hiding this comment

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

In the clean method, catching and re-raising ValidationError is unnecessary. The validate_ticket method should directly raise ValidationError, and the clean method should allow it to propagate naturally.

row=attrs["row"],
seat=attrs["seat"],
movie_session=attrs["movie_session"],
error_to_raise=serializers.ValidationError

Choose a reason for hiding this comment

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

The use of error_to_raise in the validate method is unconventional. Typically, validation methods directly raise serializers.ValidationError without passing an error class as a parameter. Consider removing this parameter and directly raising serializers.ValidationError.

tickets_data = validated_data.pop("tickets")
order = Order.objects.create(**validated_data)
for ticket_data in tickets_data:
Ticket.objects.create(order=order, **ticket_data)

Choose a reason for hiding this comment

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

Ensure that the creation of Ticket instances respects all validation constraints, including those defined in the Ticket model's clean method. This will help maintain data integrity within the transaction.


genres = self.request.query_params.get("genres", None)
if genres:
genres_ids = [int(str_id) for str_id in genres.split(",")]

Choose a reason for hiding this comment

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

Consider adding error handling for the conversion of genres query parameter to integers. If a non-integer value is passed, it will raise a ValueError. You might want to handle this exception to avoid server errors.


actors = self.request.query_params.get("actors", None)
if actors:
actors_ids = [int(str_id) for str_id in actors.split(",")]

Choose a reason for hiding this comment

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

Consider adding error handling for the conversion of actors query parameter to integers. If a non-integer value is passed, it will raise a ValueError. You might want to handle this exception to avoid server errors.

pagination_class = OrderPagination

def get_queryset(self):
return self.queryset.filter(user=self.request.user)

Choose a reason for hiding this comment

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

The get_queryset method assumes that the user is authenticated. Ensure that this viewset is protected by authentication and permission classes to prevent unauthorized access.

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 cinema application! 🎉 The code is well-structured and meets the core requirements of the task. While there are a few minor issues, such as ensuring a blank line at the end of files and validating the error_to_raise parameter, these do not significantly impact the functionality. Keep up the good work, and consider the feedback to further enhance your code quality in future projects! 😊

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

row: int,
seat: int,
movie_session: MovieSession,
error_to_raise

Choose a reason for hiding this comment

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

The error_to_raise parameter is expected to be a callable exception class. Ensure that it is always passed a valid exception class that can be instantiated with a dictionary of errors. Consider adding a check to ensure error_to_raise is callable before using it.

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