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

Develop #683

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

Develop #683

wants to merge 12 commits into from

Conversation

Lev2098
Copy link

@Lev2098 Lev2098 commented Dec 9, 2024

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! 🌟 While your code is mostly well-implemented, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Import Statement Syntax Error: There's a syntax error in your import statement. Ensure you use the correct syntax: from rest_framework.permissions import BasePermission, SAFE_METHODS.

  2. Permission Classes in OrderViewSet: The OrderViewSet is missing the custom permission class IsAdminOrIfAuthenticatedReadOnly. This is crucial for ensuring the correct access control as per the task requirements.

  3. Namespace in urls.py: The namespace should be defined in the app_name variable within the urls.py files of the respective apps (cinema and user). This is important for proper URL namespacing.

  4. Redundant Permission in GenreViewSet: The permission_classes for GenreViewSet includes both IsAdminOrIfAuthenticatedReadOnly and IsAuthenticated. This redundancy should be resolved by removing IsAuthenticated.

  5. File Organization: There are duplicate or unnecessary files in your project. Please clean up any duplicate files to maintain a clean and organized codebase.

Once these issues are resolved, your code will be in great shape! Keep up the great work, and I'm looking forward to seeing the improvements. 😊

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

@@ -0,0 +1,21 @@
from rest_framework.permissions import BasePermission, SAFE_METHODS

Choose a reason for hiding this comment

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

There is a syntax error in the import statement. The correct syntax should be from rest_framework.permissions import BasePermission, SAFE_METHODS without the slash (/).

cinema/views.py Outdated
@@ -24,21 +29,29 @@
class GenreViewSet(viewsets.ModelViewSet):
queryset = Genre.objects.all()
serializer_class = GenreSerializer
authentication_classes = (TokenAuthentication,)
permission_classes = (IsAdminOrIfAuthenticatedReadOnly, IsAuthenticated)

Choose a reason for hiding this comment

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

The permission_classes for GenreViewSet includes both IsAdminOrIfAuthenticatedReadOnly and IsAuthenticated. This is redundant because IsAdminOrIfAuthenticatedReadOnly already handles both admin and authenticated user permissions. You can remove IsAuthenticated from this tuple.

@@ -4,5 +4,6 @@
urlpatterns = [
path("admin/", admin.site.urls),
path("api/cinema/", include("cinema.urls", namespace="cinema")),
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.

The include function is used with a namespace argument, but the namespace should be defined in the included urls.py files of the respective apps (cinema and user). Ensure that the urls.py files in these apps have a namespace defined in their app_name variable.

Refactor ViewSets to use specific mixins for improved code clarity and maintainability. Adjust authentication and permissions in settings, adding TokenAuthentication as the default and setting a new custom permission class for the project. This change helps streamline operations and ensures appropriate access control.
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 submission! 🎉 While the code has been approved to help you move forward with your learning, there are a few critical issues that need attention:

  1. Import Statement Syntax Error: In cinema/permissions.py, ensure the import statement is correct: from rest_framework.permissions import BasePermission, SAFE_METHODS.

  2. Permission Classes in OrderViewSet: Update the OrderViewSet in cinema/views.py to use the custom permission class IsAdminOrIfAuthenticatedReadOnly for proper access control.

  3. Namespace in urls.py: Verify that the app_name variable is correctly set in the urls.py files for both the cinema and user apps to avoid namespace-related issues.

  4. File Organization: Remove any duplicate files to maintain a clean and organized codebase.

Addressing these issues will enhance the functionality and maintainability of your project. Keep up the good work, and continue to learn and improve! 🚀

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

@@ -0,0 +1,21 @@
from rest_framework.permissions import BasePermission, SAFE_METHODS

Choose a reason for hiding this comment

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

There is a syntax error in the import statement. The correct syntax should be: from rest_framework.permissions import BasePermission, SAFE_METHODS.

queryset = Order.objects.prefetch_related(
"tickets__movie_session__movie", "tickets__movie_session__cinema_hall"
)
serializer_class = OrderSerializer
pagination_class = OrderPagination
permission_classes = (IsAuthenticated,)

Choose a reason for hiding this comment

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

The OrderViewSet is missing the custom permission class IsAdminOrIfAuthenticatedReadOnly. This is crucial for ensuring the correct access control as per the task requirements. Please add it to the permission_classes.

@@ -4,5 +4,6 @@
urlpatterns = [
path("admin/", admin.site.urls),
path("api/cinema/", include("cinema.urls", namespace="cinema")),
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.

The namespace argument in the include function requires that the app_name variable is defined in the urls.py files of the respective apps (cinema and user). Please ensure that the app_name is correctly set in those files to avoid any namespace-related issues.

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