Merge pull request #3904 from jumpserver/dev

[Bugfix] 修复显示未授权资产的bug
pull/3974/head
老广 2020-04-15 23:17:08 -05:00 committed by GitHub
commit 9426f58a6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -76,9 +76,15 @@ class TreeService(Tree):
ancestor_ids.pop(0)
return ancestor_ids
def ancestors(self, nid, with_self=False, deep=False):
def ancestors(self, nid, with_self=False, deep=False, with_assets=True):
ancestor_ids = self.ancestors_ids(nid, with_self=with_self)
return [self.get_node(i, deep=deep) for i in ancestor_ids]
ancestors = [self.get_node(i, deep=deep) for i in ancestor_ids]
if with_assets:
return ancestors
for n in ancestors:
n.data['assets'] = set()
n.data['all_assets'] = None
return ancestors
def get_node_full_tag(self, nid):
ancestors = self.ancestors(nid, with_self=True)

View File

@ -290,7 +290,7 @@ class AssetPermissionUtil(AssetPermissionUtilCacheMixin):
def parse_user_tree_to_full_tree(self, user_tree):
"""
经过前面两个动作用户授权的节点已放到树上但是树不是完整的
这里要讲树构造成一个完整的
这里要讲树构造成一个完整的
"""
# 开始修正user_tree保证父节点都在树上
root_children = user_tree.children('')
@ -300,7 +300,8 @@ class AssetPermissionUtil(AssetPermissionUtilCacheMixin):
if child.identifier.startswith('-'):
continue
ancestors = self.full_tree.ancestors(
child.identifier, with_self=False, deep=True
child.identifier, with_self=False, deep=True,
with_assets=False,
)
if not ancestors:
continue