Commit cdbdc853 authored by ibuler's avatar ibuler

Merge branch 'bugfix' of github.com:jumpserver/jumpserver into bugfix

parents c3a54a89 28ec1eb0
This diff is collapsed.
......@@ -299,12 +299,14 @@ class UserGrantedNodeAssetsApi(UserPermissionCacheMixin, AssetsFilterMixin, List
nodes = util.get_nodes_with_assets()
if str(node_id) == const.UNGROUPED_NODE_ID:
node = util.tree.ungrouped_node
elif str(node_id) == const.EMPTY_NODE_ID:
node = util.tree.empty_node
else:
node = get_object_or_404(Node, id=node_id)
if node == util.tree.root_node:
assets = util.get_assets()
else:
assets = nodes.get(node, [])
assets = nodes.get(node, {})
for asset, system_users in assets.items():
asset.system_users_granted = system_users
......
......@@ -2,3 +2,4 @@
#
UNGROUPED_NODE_ID = "00000000-0000-0000-0000-000000000002"
EMPTY_NODE_ID = "00000000-0000-0000-0000-000000000003"
......@@ -109,6 +109,13 @@ class GenerateTree:
self._ungroup_node = node
return node
@property
def empty_node(self):
node_id = const.EMPTY_NODE_ID
value = _('Empty')
node = Node(id=node_id, value=value)
return node
#@timeit
def add_assets_without_system_users(self, assets):
for asset in assets:
......@@ -176,6 +183,9 @@ class GenerateTree:
for node, values in self.nodes.items():
node._assets_amount = values["assets_amount"]
nodes[node] = {asset: self.assets.get(asset, {}) for asset in values["assets"]}
# 如果返回空节点,页面构造授权资产树报错
if not nodes:
nodes[self.empty_node] = {}
self._nodes_with_assets = nodes
return dict(nodes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment