mirror of https://github.com/jumpserver/jumpserver
commit
9426f58a6b
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue