-
Notifications
You must be signed in to change notification settings - Fork 707
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 #746
base: master
Are you sure you want to change the base?
Solution #746
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.
Thank you for your hard work on this project! There are a few critical issues that need to be addressed before we can approve the pull request.
-
validate_seat_and_row
Method: In both themodels.py
andserializers.py
files, thevalidate_seat_and_row
method is incorrectly using theerror_to_raise
parameter. It should be called with an error message dictionary as an argument, likeraise error_to_raise({...})
. This is crucial for proper error handling. -
Action Comparison: In the
views.py
file, ensure thatself.action
is compared to a list of strings, not a tuple. Useif self.action in ['list', 'retrieve']:
to avoid logical errors. -
Pagination Configuration: The
settings.py
file lacks pagination settings, which are required as per the task description. Please add the necessary pagination configuration.
These changes are important to ensure the functionality and correctness of the application. Once these issues are resolved, your code will be in great shape! 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/models.py
Outdated
row: int, | ||
seat: int, | ||
movie_session, | ||
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 that raises an exception. However, it is being used directly in the raise
statement. Consider changing the usage to raise error_to_raise(...)
to properly raise the exception.
raise error_to_raise({ | ||
"row": f"Row must be in the range [1, {cinema_hall.rows}]" | ||
}) |
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 should be called with the error message dictionary as an argument, like raise error_to_raise({...})
.
raise error_to_raise({ | ||
"seat": f"Seat must be in the range " | ||
f"[1, {cinema_hall.seats_in_row}]" | ||
}) |
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.
Similar to the previous comment, ensure that error_to_raise
is called with the error message dictionary as an argument, like raise error_to_raise({...})
.
attrs["row"], | ||
attrs["seat"], | ||
attrs["movie_session"], | ||
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.
Ensure that the validate_seat_and_row
method is correctly using the serializers.ValidationError
as a callable to raise the exception. The method should be called with the error message dictionary as an argument, like raise serializers.ValidationError({...})
.
cinema/views.py
Outdated
if self.action == ("list", "retrieve"): | ||
queryset = Movie.objects.prefetch_related("actors") |
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 condition if self.action == ('list', 'retrieve'):
is incorrect. The self.action
attribute is a string representing the current action, so it should be compared to a single string, not a tuple. Consider using if self.action in ['list', 'retrieve']:
instead.
if self.action in ["list", "retrieve"]: | ||
queryset = queryset.prefetch_related("movie") |
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.
Similar to the previous comment, ensure that self.action
is compared to a list of strings, not a tuple. Use if self.action in ['list', 'retrieve']:
.
… views, and add pagination settings
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 effort on your work with the cinema application! 🎬 While there are a few critical issues that need attention, your progress is commendable. Here are the key areas to focus on:
-
validate_seat_and_row
Method: In both themodels.py
andserializers.py
files, ensure that theerror_to_raise
parameter is used correctly by calling it with an error message dictionary, likeraise error_to_raise({...})
. This is essential for proper error handling. -
Action Comparison: In the
views.py
file, update the comparison ofself.action
to usein
with a list of strings, such asif self.action in ['list', 'retrieve']:
. This will prevent logical errors in your code. -
Pagination Configuration: The
settings.py
file needs the necessary pagination settings as per the task requirements. Make sure to uncomment and configure these settings to ensure your API supports pagination correctly.
These improvements are crucial for the functionality of your application. Addressing them will enhance your code quality and help you avoid similar issues in the future. 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! ✨
error_to_raise=ValidationError | ||
): | ||
cinema_hall = movie_session.cinema_hall | ||
|
||
if not (1 <= row <= cinema_hall.rows): | ||
raise error_to_raise({ | ||
"row": f"Row must be in the range [1, {cinema_hall.rows}]" | ||
}) | ||
|
||
if not (1 <= seat <= cinema_hall.seats_in_row): | ||
raise error_to_raise({ | ||
"seat": f"Seat must be in the range " | ||
f"[1, {cinema_hall.seats_in_row}]" | ||
}) |
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 validate_seat_and_row
method is incorrectly using the error_to_raise
parameter. It should be called with an error message dictionary as an argument, like raise error_to_raise({...})
. This is crucial for proper error handling.
Ticket.validate_seat_and_row( | ||
attrs["row"], | ||
attrs["seat"], | ||
attrs["movie_session"], | ||
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 validate_seat_and_row
method is incorrectly using the error_to_raise
parameter. It should be called with an error message dictionary as an argument, like raise error_to_raise({...})
. This is crucial for proper error handling.
if self.action == ["list", "retrieve"]: | ||
queryset = Movie.objects.prefetch_related("actors") |
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 comparison if self.action == ['list', 'retrieve']:
is incorrect. It should be if self.action in ['list', 'retrieve']:
to properly check if the action is either 'list' or 'retrieve'.
cinema_service/settings.py
Outdated
# REST_FRAMEWORK = { | ||
# "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination", | ||
# "PAGE_SIZE": 1 | ||
# } |
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 pagination settings are commented out. According to the task description, pagination configuration is required. Please uncomment and configure the pagination settings to ensure proper functionality.
No description provided.