Skip to content

Commit

Permalink
fix: 修复项目编辑权限异常的问题 --story=119807844
Browse files Browse the repository at this point in the history
  • Loading branch information
benero committed Sep 24, 2024
1 parent 04359c3 commit 1076c95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions itsm/component/drf/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ def has_object_permission(self, request, view, obj, **kwargs):
if hasattr(view, "permission_action_mapping"):
apply_actions = view.permission_action_mapping.get(view.action)

# 默认动作
if not apply_actions and hasattr(view, "permission_action_default"):
apply_actions = view.permission_action_default

if isinstance(apply_actions, str):
apply_actions = [apply_actions]

return self.iam_auth(request, apply_actions, obj)

def iam_auth(self, request, apply_actions, obj=None):
Expand Down
4 changes: 3 additions & 1 deletion itsm/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ class ProjectViewSet(component_viewsets.AuthModelViewSet):
"name": ["exact", "contains", "startswith", "icontains"],
}

permission_action_default = ["project_edit"]
permission_action_mapping = {
"retrieve": ["project_view"]
"retrieve": ["project_view"],
"update_project_record": ["project_view"]
}

def list(self, request, *args, **kwargs):
Expand Down

0 comments on commit 1076c95

Please sign in to comment.