mirror of https://github.com/jumpserver/jumpserver
fix: 修复工单相应bug
parent
ee757e261d
commit
3a26b9d102
|
@ -28,7 +28,7 @@ class ApplicationViewSet(SuggestionMixin, OrgBulkModelViewSet):
|
||||||
}
|
}
|
||||||
rbac_perms = {
|
rbac_perms = {
|
||||||
'get_tree': 'applications.view_application',
|
'get_tree': 'applications.view_application',
|
||||||
'match': 'assets.match_application'
|
'match': 'applications.match_application'
|
||||||
}
|
}
|
||||||
|
|
||||||
@action(methods=['GET'], detail=False, url_path='tree')
|
@action(methods=['GET'], detail=False, url_path='tree')
|
||||||
|
|
|
@ -32,6 +32,7 @@ class SimpleMetadataWithFilters(SimpleMetadata):
|
||||||
the fields that are accepted for 'PUT' and 'POST' methods.
|
the fields that are accepted for 'PUT' and 'POST' methods.
|
||||||
"""
|
"""
|
||||||
actions = {}
|
actions = {}
|
||||||
|
view.raw_action = view.action
|
||||||
for method in self.methods & set(view.allowed_methods):
|
for method in self.methods & set(view.allowed_methods):
|
||||||
if hasattr(view, 'action_map'):
|
if hasattr(view, 'action_map'):
|
||||||
view.action = view.action_map.get(method.lower(), view.action)
|
view.action = view.action_map.get(method.lower(), view.action)
|
||||||
|
|
|
@ -54,6 +54,7 @@ class RBACPermission(permissions.DjangoModelPermissions):
|
||||||
def get_default_action_perms(self, model_cls):
|
def get_default_action_perms(self, model_cls):
|
||||||
if model_cls is None:
|
if model_cls is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
perms = {}
|
perms = {}
|
||||||
for action, tmpl in dict(self.default_rbac_perms_tmpl).items():
|
for action, tmpl in dict(self.default_rbac_perms_tmpl).items():
|
||||||
perms[action] = self.format_perms(tmpl, model_cls)
|
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:
|
def get_rbac_perms(self, view, model_cls) -> dict:
|
||||||
if hasattr(view, 'get_rbac_perms'):
|
if hasattr(view, 'get_rbac_perms'):
|
||||||
return dict(view.get_rbac_perms())
|
return dict(view.get_rbac_perms())
|
||||||
perms = self.get_default_action_perms(model_cls)
|
perms = {}
|
||||||
if hasattr(view, 'rbac_perms'):
|
if hasattr(view, 'rbac_perms'):
|
||||||
perms.update(dict(view.rbac_perms))
|
perms.update(dict(view.rbac_perms))
|
||||||
|
if '*' not in perms:
|
||||||
|
perms.update(self.get_default_action_perms(model_cls))
|
||||||
return perms
|
return perms
|
||||||
|
|
||||||
def _get_action_perms(self, action, model_cls, view):
|
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:
|
if request.user.is_anonymous and self.authenticated_users_only:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
action = getattr(view, 'action', None)
|
raw_action = getattr(view, 'raw_action', None)
|
||||||
if action == 'metadata':
|
if raw_action == 'metadata':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
perms = self.get_require_perms(request, view)
|
perms = self.get_require_perms(request, view)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class TicketViewSet(CommonApiMixin, viewsets.ModelViewSet):
|
||||||
)
|
)
|
||||||
ordering = ('-date_created',)
|
ordering = ('-date_created',)
|
||||||
rbac_perms = {
|
rbac_perms = {
|
||||||
'open': 'tickets.view_ticket'
|
'open': 'tickets.view_ticket',
|
||||||
}
|
}
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
|
|
Loading…
Reference in New Issue