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

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

Solution #665

wants to merge 4 commits into from

Conversation

sofiazholud
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 pull request! While you've made great progress, there are a few critical issues that need to be addressed before we can approve it:

  1. Permission Class Implementation: The IsAdminOrIfAuthenticatedReadOnly permission class needs to be adjusted to ensure administrators have full access while regular authenticated users have read-only access. This is crucial for meeting the core requirements of the task.

  2. ViewSet Permissions: The GenreViewSet, CinemaHallViewSet, and ActorViewSet should allow both list and create actions for all users, not just admins. This misalignment with the task requirements affects functionality.

  3. Missing Tests: There are no tests provided for user/tests and cinema/tests. Tests are essential to ensure the functionality works as expected and meets the task requirements.

Please address these issues to ensure the code meets the core requirements and functions correctly. Once these are resolved, we'll be happy to take another look. Keep up the great work! 😊

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

Comment on lines 12 to 14
return bool(
request.method
in SAFE_METHODS

Choose a reason for hiding this comment

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

The check request.method in SAFE_METHODS is redundant here because it is already checked in the if statement on line 11. You can simplify the logic by removing the repeated check within the bool() function.

cinema/views.py Outdated
return MovieSessionSerializer


class OrderPagination(PageNumberPagination):
page_size = 10
max_page_size = 100
permission_classes = (IsAuthenticated,)

Choose a reason for hiding this comment

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

The OrderPagination class should not have permission_classes defined. Pagination classes do not handle permissions, so this line should be removed.

cinema/views.py Outdated


class MovieViewSet(viewsets.ModelViewSet):
queryset = Movie.objects.prefetch_related("genres", "actors")
serializer_class = MovieSerializer
permission_classes = [IsAuthenticated]
http_method_names = ["get", "post"]

Choose a reason for hiding this comment

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

The http_method_names in MovieViewSet should include 'put' and 'patch' to allow updating movies, as specified in the task requirements.

@@ -5,4 +5,5 @@
path("admin/", admin.site.urls),
path("api/cinema/", include("cinema.urls", namespace="cinema")),

Choose a reason for hiding this comment

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

Ensure that the cinema.urls module defines a namespace 'cinema' since you are using namespace="cinema" in the include function.

@@ -5,4 +5,5 @@
path("admin/", admin.site.urls),
path("api/cinema/", include("cinema.urls", namespace="cinema")),
path("__debug__/", include("debug_toolbar.urls")),
path("api/user/", include("user.urls", namespace="user")),

Choose a reason for hiding this comment

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

Ensure that the user.urls module defines a namespace 'user' since you are using namespace="user" in the include function.

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 several key aspects of the task! 🎉 Your work on the IsAdminOrIfAuthenticatedReadOnly permission class and the UserSerializer is spot on, ensuring secure and appropriate access control and user data handling. However, there are a few critical areas that need attention:

  1. ViewSet Permissions: The GenreViewSet, CinemaHallViewSet, and ActorViewSet currently restrict the create action to administrators only. The task requires that both list and create actions be accessible to all users. Please adjust the permissions to align with this requirement.

  2. Missing Tests: There are no test files provided for user/tests and cinema/tests. Tests are crucial for verifying that your code functions as expected and meets the task requirements. Make sure to add these to ensure robustness.

Remember, addressing these issues will not only help you meet the task requirements but also enhance your coding skills. Keep up the good work, and use this feedback to improve your implementation. Your progress is commendable, and with a few adjustments, your solution will be even stronger. 🚀

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

Comment on lines +38 to +40
if self.action == "create":
return [IsAdminUser()]
return [IsAuthenticated()]

Choose a reason for hiding this comment

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

The get_permissions method in GenreViewSet restricts the create action to admins only. According to the task requirements, both list and create actions should be accessible to all users, not just admins. Consider removing the permission restriction for the create action.

Comment on lines +50 to +52
if self.action == "create":
return [IsAdminUser()]
return [IsAuthenticated()]

Choose a reason for hiding this comment

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

The get_permissions method in ActorViewSet restricts the create action to admins only. As per the task requirements, both list and create actions should be accessible to all users. Consider adjusting the permissions to allow all users to create.

Comment on lines +62 to +64
if self.action == "create":
return [IsAdminUser()]
return [IsAuthenticated()]

Choose a reason for hiding this comment

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

The get_permissions method in CinemaHallViewSet restricts the create action to admins only. The task specifies that both list and create actions should be available to all users. Please modify the permissions to meet this requirement.

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