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

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

solution #698

wants to merge 2 commits into from

Conversation

sofiiasavkova
Copy link

No description provided.

cinema/views.py Outdated
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
GenericViewSet,
):
Copy link

Choose a reason for hiding this comment

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

You can leave MovieSessionViewSet as ModelViewSet as it already implements all these actions

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

  1. OrderViewSet Permissions: The OrderViewSet does not properly handle permissions for the 'create' action, which could lead to unauthorized access. Please ensure that the IsAuthenticated permission is correctly applied when creating an order without overriding other permissions.

  2. MovieSessionViewSet Validation: The MovieSessionViewSet lacks proper validation for date and movie ID inputs. This could lead to errors if invalid data is provided. Adding validation will help ensure the application functions correctly and securely.

  3. Security Settings in settings.py: The SECRET_KEY is hardcoded and exposed, and DEBUG is set to True. These are not suitable for production environments. Please adjust these settings to enhance security.

  4. Namespace in URLs: Ensure that the 'cinema/urls.py' file defines an app_name variable to match the namespace specified in the include function. This will help prevent URL name conflicts across different apps.

  5. Permission Handling: Raising a NotAuthenticated exception directly in the has_permission method might lead to inconsistent behavior. Consider returning False instead to allow the framework to handle authentication failures uniformly.

Once these issues are resolved, your code will be in great shape! Keep up the excellent work, and feel free to reach out if you have any questions or need further assistance. 😊

✨ 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/views.py Outdated Show resolved Hide resolved
cinema_service/urls.py Show resolved Hide resolved
user/permissions.py Show resolved Hide resolved
user/serializers.py Show resolved Hide resolved
user/serializers.py Show resolved Hide resolved
user/serializers.py Show resolved Hide resolved
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 most of the issues from the previous review! 🎉 Your code is progressing well, and it's clear that you're putting in a lot of effort. Here are some key points to focus on for future improvements:

  1. OrderViewSet Permissions: Ensure that the IsAuthenticated permission is correctly applied when creating an order. This is crucial to prevent unauthorized access.

  2. Permission Handling: Instead of raising PermissionDenied or NotAuthenticated exceptions directly in methods like perform_create, perform_update, and perform_destroy, consider using permission classes for more consistent behavior.

  3. Security Settings: The SECRET_KEY is still hardcoded in settings.py. It's important to address this by using environment variables to enhance the security of your application.

  4. Namespace in URLs: Make sure the app_name variable is defined in cinema/urls.py to prevent URL name conflicts across different apps.

You've made significant progress, and with a few more adjustments, your code will be even stronger. Keep up the great work, and remember to review the comments to enhance your learning and coding skills. 🚀

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

Comment on lines +139 to +143
def perform_create(self, serializer):
if not self.request.user.is_staff:
raise PermissionDenied(
"You do not have permission to perform this action."
)

Choose a reason for hiding this comment

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

Raising a PermissionDenied exception directly in the perform_create method might lead to inconsistent behavior. Consider using permission classes to handle these checks more uniformly.

Comment on lines +146 to +150
def perform_update(self, serializer):
if not self.request.user.is_staff:
raise PermissionDenied(
"You do not have permission to perform this action."
)

Choose a reason for hiding this comment

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

Raising a PermissionDenied exception directly in the perform_update method might lead to inconsistent behavior. Consider using permission classes to handle these checks more uniformly.

Comment on lines +153 to +157
def perform_destroy(self, instance):
if not self.request.user.is_staff:
raise PermissionDenied(
"You do not have permission to perform this action."
)

Choose a reason for hiding this comment

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

Raising a PermissionDenied exception directly in the perform_destroy method might lead to inconsistent behavior. Consider using permission classes to handle these checks more uniformly.

Comment on lines +181 to +183
def get_permissions(self):
if self.action == "create":
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 OrderViewSet should ensure that the IsAuthenticated permission is correctly applied when creating an order without overriding other permissions. This could lead to unauthorized access.


urlpatterns = [
path("admin/", admin.site.urls),
path("api/token-auth/", views.obtain_auth_token, name="token-auth"),
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.py' file defines an app_name variable to match the namespace specified here. This will help prevent URL name conflicts across different apps.

class IsAdminOrIfAuthenticatedReadOnly(BasePermission):
def has_permission(self, request, view):
if not request.user.is_authenticated:
raise NotAuthenticated()

Choose a reason for hiding this comment

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

Raising a NotAuthenticated exception directly in the has_permission method might lead to inconsistent behavior. Consider returning False instead to allow the framework to handle authentication failures uniformly.

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