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

fix: permission check object id param #667

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/unfold/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def inner(
getattr(model_admin, f"has_{permission}_permission")
for permission in permissions
)
# TODO add obj parameter into has_permission method call.
# Permissions methods have following syntax: has_<some>_permission(self, request, obj=None):
# But obj is not examined by default in django admin and it would also require additional
# fetch from database, therefore it is not supported yet
if not any(
has_permission(request) for has_permission in permission_checks
has_permission(request, kwargs.get("object_id"))
for has_permission in permission_checks
):
raise PermissionDenied
return func(model_admin, request, *args, **kwargs)
Expand Down