Skip to content

Commit

Permalink
Add reject and revoke acceptance exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Jan 24, 2025
1 parent 1d432d5 commit 7379d80
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions backend/core/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ def has_object_permission(self, request: Request, view, obj):
):
return True
perm = Permission.objects.get(codename=_codename)

# special case of risk acceptance approval
if (
request.parser_context["request"]._request.resolver_match.url_name
== "risk-acceptances-accept"
):
if request.parser_context and request.parser_context[
"request"
]._request.resolver_match.url_name in [
"risk-acceptances-accept",
"risk-acceptances-reject",
"risk-acceptances-revoke",
]:
perm = Permission.objects.get(codename="approve_riskacceptance")

return RoleAssignment.is_access_allowed(
user=request.user,
perm=perm,
Expand Down

0 comments on commit 7379d80

Please sign in to comment.