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-py-token-authentication #695

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

Conversation

skyfoxwork
Copy link

No description provided.

Copy link

@pohgen pohgen left a comment

Choose a reason for hiding this comment

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

except for one flaw, you've made a good solution

Comment on lines +68 to +69
authentication_classes = (TokenAuthentication,)
permission_classes = (IsAdminOrIfAuthenticatedReadOnly,)
Copy link

Choose a reason for hiding this comment

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

you can write it in settings and not dublicate it across all views

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. Specifically, there's a syntax error in the import statement of your custom permission class, which could impact the functionality of your code. Additionally, there are duplicate files and a missing blank line at the end of some files, which could lead to confusion and maintenance challenges in the future. Please resolve these issues, and feel free to reach out if you need any help! 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.

@@ -0,0 +1,12 @@
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 /.

from rest_framework.pagination import PageNumberPagination
from rest_framework.permissions import IsAuthenticated

Choose a reason for hiding this comment

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

The IsAuthenticated permission is imported but not used in this file. Consider removing it if it's not needed to keep the code clean.

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 addressing the initial issues with the syntax error and duplicate files! 🎉 While there are still a few areas that need attention, such as the duplicate user/urls.py file and the missing blank line at the end of files, these are minor and can be easily fixed.

Key Points to Address:

  1. Duplicate Files: Remove the duplicate user/urls.py file to avoid confusion.
  2. Code Style: Ensure all files end with a blank line as per coding standards.
  3. Import Syntax: Correct the syntax error in the import statement by using a comma to separate modules.
  4. Permission Classes: Verify that the OrderViewSet uses the correct permission class (IsAuthenticated vs. IsAdminOrIfAuthenticatedReadOnly) to match your intended access control logic.
  5. Settings Configuration: Remember to set DEBUG to False and secure the SECRET_KEY for production environments. Also, consider setting USE_TZ to True to handle time zones properly.
  6. Namespace Definition: Ensure that the cinema and user apps define their namespaces to prevent potential errors.

These improvements will enhance the functionality and maintainability of your code. Keep up the good work, and make sure to address these points in future iterations to continue growing as a developer! 🚀

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

@@ -0,0 +1,12 @@
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. You should use a comma to separate the imported modules: 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
authentication_classes = (TokenAuthentication,)
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 uses IsAuthenticated for permission_classes, which is different from the other viewsets that use IsAdminOrIfAuthenticatedReadOnly. Ensure this is intentional and aligns with the intended permission logic for orders.

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

Ensure that the cinema.urls and user.urls modules define the namespaces cinema and user, respectively. If not, this will cause a NamespaceNotFound error.

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.

3 participants