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

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

Solution #703

wants to merge 7 commits into from

Conversation

MrEgorLite
Copy link

No description provided.

Copy link

@MatvijSafonov MatvijSafonov left a comment

Choose a reason for hiding this comment

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

GJ
!

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. Security Concern: The SECRET_KEY is hardcoded in the settings file. This poses a significant security risk, especially in production environments. It's crucial to use environment variables or a secure vault to manage sensitive information like the SECRET_KEY.

  2. Permission Classes Missing: The CinemaHallViewSet, ActorViewSet, and GenreViewSet do not specify any permission classes. It's important to define these to control access appropriately, ensuring that only authorized users can perform certain actions.

  3. Permission Logic Issue: In the ListAndCreateOnly class, the result of super().has_permission(request, view) is not returned. This oversight means that the permission logic isn't correctly applied, potentially allowing unauthorized access.

Please address these issues to ensure the functionality and security of your application. Once resolved, your code will be in great shape! Keep up the good work, and don't hesitate to reach out if you need any 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.

def has_permission(self, request, view):
if view.action in ("list", "create"):
return True
super().has_permission(request, view)

Choose a reason for hiding this comment

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

The super().has_permission(request, view) method is called, but its result is not returned. This means the method will always return None if the action is not 'list' or 'create'. You should return the result of the super() call to ensure the permission logic is correctly applied.

Comment on lines +25 to 31
class GenreViewSet(
mixins.ListModelMixin,
mixins.CreateModelMixin,
viewsets.GenericViewSet
):
queryset = Genre.objects.all()
serializer_class = GenreSerializer

Choose a reason for hiding this comment

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

The GenreViewSet does not specify any permission classes. Consider adding permission classes to control access to this viewset, especially if it should be restricted to authenticated users or specific roles.

Comment on lines +34 to 40
class ActorViewSet(
mixins.ListModelMixin,
mixins.CreateModelMixin,
viewsets.GenericViewSet
):
queryset = Actor.objects.all()
serializer_class = ActorSerializer

Choose a reason for hiding this comment

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

The ActorViewSet does not specify any permission classes. Consider adding permission classes to control access to this viewset, especially if it should be restricted to authenticated users or specific roles.

Comment on lines +43 to 49
class CinemaHallViewSet(
mixins.ListModelMixin,
mixins.CreateModelMixin,
viewsets.GenericViewSet
):
queryset = CinemaHall.objects.all()
serializer_class = CinemaHallSerializer

Choose a reason for hiding this comment

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

The CinemaHallViewSet does not specify any permission classes. Consider adding permission classes to control access to this viewset, especially if it should be restricted to authenticated users or specific roles.

Comment on lines +23 to 26
SECRET_KEY = os.environ.get(
"SECRET_KEY",
"django-insecure-6vubhk2$++agnctay_4pxy_8cq)mosmn(*-#2b^v4cgsh-^!i3"
)

Choose a reason for hiding this comment

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

The SECRET_KEY is hardcoded with a default value. This is a security risk, especially in production environments. Consider using environment variables or a secure vault to manage the SECRET_KEY without exposing it in the source code.

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.

Review Summary

Great job on your submission! 🎉 Your implementation is mostly well-structured and follows best practices. Here are some key points and areas for improvement:

  1. Security Concern: The SECRET_KEY is currently retrieved from an environment variable but falls back to a hardcoded insecure key. It's crucial to remove this fallback and ensure the environment variable is set in all environments to enhance security.

  2. Permission Classes: The MovieViewSet and MovieSessionViewSet currently lack specified permission classes. Consider adding appropriate permissions, such as IsAdminOrIfAuthenticatedReadOnly, to control access and ensure only authorized users can perform certain actions.

Despite these issues, your code meets the task requirements, and the decision to approve is made to help you move forward with your learning. Please review the comments and address these critical issues in future iterations to avoid similar problems. Keep up the good work and continue improving your code! 🚀

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

mixins.RetrieveModelMixin,
mixins.CreateModelMixin,
viewsets.GenericViewSet
):
queryset = Movie.objects.prefetch_related("genres", "actors")
serializer_class = MovieSerializer

Choose a reason for hiding this comment

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

The MovieViewSet does not specify any permission classes. Consider adding appropriate permission classes to control access, such as IsAdminOrIfAuthenticatedReadOnly.

Comment on lines +23 to 26
SECRET_KEY = os.environ.get(
"SECRET_KEY",
"django-insecure-6vubhk2$++agnctay_4pxy_8cq)mosmn(*-#2b^v4cgsh-^!i3"
)

Choose a reason for hiding this comment

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

The SECRET_KEY should not have a hardcoded fallback value. Consider removing the default insecure key and ensure that the environment variable is set in all environments to enhance security.

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