fix: 修复工单相应bug

pull/7880/head
feng626 2022-03-16 16:21:00 +08:00 committed by Jiangjie.Bai
parent ee757e261d
commit 3a26b9d102
4 changed files with 9 additions and 5 deletions

View File

@ -28,7 +28,7 @@ class ApplicationViewSet(SuggestionMixin, OrgBulkModelViewSet):
}
rbac_perms = {
'get_tree': 'applications.view_application',
'match': 'assets.match_application'
'match': 'applications.match_application'
}
@action(methods=['GET'], detail=False, url_path='tree')

View File

@ -32,6 +32,7 @@ class SimpleMetadataWithFilters(SimpleMetadata):
the fields that are accepted for 'PUT' and 'POST' methods.
"""
actions = {}
view.raw_action = view.action
for method in self.methods & set(view.allowed_methods):
if hasattr(view, 'action_map'):
view.action = view.action_map.get(method.lower(), view.action)

View File

@ -54,6 +54,7 @@ class RBACPermission(permissions.DjangoModelPermissions):
def get_default_action_perms(self, model_cls):
if model_cls is None:
return {}
perms = {}
for action, tmpl in dict(self.default_rbac_perms_tmpl).items():
perms[action] = self.format_perms(tmpl, model_cls)
@ -62,9 +63,11 @@ class RBACPermission(permissions.DjangoModelPermissions):
def get_rbac_perms(self, view, model_cls) -> dict:
if hasattr(view, 'get_rbac_perms'):
return dict(view.get_rbac_perms())
perms = self.get_default_action_perms(model_cls)
perms = {}
if hasattr(view, 'rbac_perms'):
perms.update(dict(view.rbac_perms))
if '*' not in perms:
perms.update(self.get_default_action_perms(model_cls))
return perms
def _get_action_perms(self, action, model_cls, view):
@ -116,8 +119,8 @@ class RBACPermission(permissions.DjangoModelPermissions):
if request.user.is_anonymous and self.authenticated_users_only:
return False
action = getattr(view, 'action', None)
if action == 'metadata':
raw_action = getattr(view, 'raw_action', None)
if raw_action == 'metadata':
return True
perms = self.get_require_perms(request, view)

View File

@ -35,7 +35,7 @@ class TicketViewSet(CommonApiMixin, viewsets.ModelViewSet):
)
ordering = ('-date_created',)
rbac_perms = {
'open': 'tickets.view_ticket'
'open': 'tickets.view_ticket',
}
def create(self, request, *args, **kwargs):