Merge pull request #6555 from jumpserver/pr@dev@user_collection_node_fix

fix: 用户管理-用户-授权的资产-收藏夹下拉菜单报404bug修复
pull/6563/head
feng626 2021-07-28 14:39:53 +08:00 committed by GitHub
commit c1e6bc5d60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -203,7 +203,8 @@ class UserGrantedTreeRefreshController:
logger.info(f'Rebuild user tree: user={self.user} org={current_org}')
utils = UserGrantedTreeBuildUtils(user)
utils.rebuild_user_granted_tree()
logger.info(f'Rebuild user tree ok: cost={time.time() - t_start} user={self.user} org={current_org}')
logger.info(
f'Rebuild user tree ok: cost={time.time() - t_start} user={self.user} org={current_org}')
class UserGrantedUtilsBase:
@ -547,14 +548,16 @@ class UserGrantedNodesQueryUtils(UserGrantedUtilsBase):
if not key:
return self.get_top_level_nodes()
nodes = PermNode.objects.none()
if key == PermNode.FAVORITE_NODE_KEY:
return nodes
node = PermNode.objects.get(key=key)
granted_status = node.get_granted_status(self.user)
if granted_status == NodeFrom.granted:
nodes = PermNode.objects.filter(parent_key=key)
elif granted_status in (NodeFrom.asset, NodeFrom.child):
nodes = self.get_indirect_granted_node_children(key)
else:
nodes = PermNode.objects.none()
nodes = self.sort(nodes)
return nodes