-
Notifications
You must be signed in to change notification settings - Fork 702
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
base: master
Are you sure you want to change the base?
Solution #742
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
.
except ValidationError as e: | ||
raise ValidationError(e.message_dict) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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(",")] |
There was a problem hiding this comment.
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(",")] |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
No description provided.