mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-22 00:09:14 +00:00
[Bugfix] 修复显示未授权资产的bug
This commit is contained in:
@@ -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
|
||||
@@ -346,6 +347,7 @@ class AssetPermissionUtil(AssetPermissionUtilCacheMixin):
|
||||
self.add_direct_nodes_to_user_tree(user_tree)
|
||||
self.add_single_assets_node_to_user_tree(user_tree)
|
||||
self.parse_user_tree_to_full_tree(user_tree)
|
||||
print(user_tree.all_assets('2'))
|
||||
self.add_favorite_node_if_need(user_tree)
|
||||
self.set_user_tree_to_cache_if_need(user_tree)
|
||||
self.set_user_tree_to_local(user_tree)
|
||||
|
Reference in New Issue
Block a user