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

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

Solution #746

wants to merge 4 commits into from

Conversation

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

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.

  1. validate_seat_and_row Method: In both the models.py and serializers.py files, 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.

  2. Action Comparison: In the views.py file, ensure that self.action is compared to a list of strings, not a tuple. Use if self.action in ['list', 'retrieve']: to avoid logical errors.

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

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.

Comment on lines +97 to +99
raise error_to_raise({
"row": f"Row must be in the range [1, {cinema_hall.rows}]"
})

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({...}).

Comment on lines +102 to +105
raise error_to_raise({
"seat": f"Seat must be in the range "
f"[1, {cinema_hall.seats_in_row}]"
})

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

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
Comment on lines 59 to 60
if self.action == ("list", "retrieve"):
queryset = Movie.objects.prefetch_related("actors")

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.

Comment on lines +107 to +108
if self.action in ["list", "retrieve"]:
queryset = queryset.prefetch_related("movie")

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']:.

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 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:

  1. validate_seat_and_row Method: In both the models.py and serializers.py files, ensure that the error_to_raise parameter is used correctly by calling it with an error message dictionary, like raise error_to_raise({...}). This is essential for proper error handling.

  2. Action Comparison: In the views.py file, update the comparison of self.action to use in with a list of strings, such as if self.action in ['list', 'retrieve']:. This will prevent logical errors in your code.

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

Comment on lines +92 to +105
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}]"
})

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.

Comment on lines +124 to +129
Ticket.validate_seat_and_row(
attrs["row"],
attrs["seat"],
attrs["movie_session"],
serializers.ValidationError
)

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.

Comment on lines +59 to +60
if self.action == ["list", "retrieve"]:
queryset = Movie.objects.prefetch_related("actors")

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

Comment on lines 131 to 134
# REST_FRAMEWORK = {
# "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
# "PAGE_SIZE": 1
# }

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.

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