Browse Source

feat: 修复获取用户授权的资产账号列表

pull/8931/head
Jiangjie.Bai 2 years ago
parent
commit
881c0a6042
  1. 4
      apps/perms/models/asset_permission.py
  2. 2
      apps/perms/utils/user_permission.py

4
apps/perms/models/asset_permission.py

@ -78,7 +78,7 @@ class AssetPermissionQuerySet(models.QuerySet):
return self.filter(q)
def filter_by_accounts(self, accounts):
q = Q(accounts__contains=accounts) | \
q = Q(accounts__contains=list(accounts)) | \
Q(accounts__contains=AssetPermission.SpecialAccount.ALL.value)
return self.filter(q)
@ -238,7 +238,7 @@ class AssetPermission(OrgModelMixin):
# set account actions
account_names = accounts.values_list('username', flat=True)
perms = perms.filter_by_accounts(account_names)
account_names_actions_map = defaultdict(set)
account_names_actions_map = defaultdict(int)
account_names_actions = perms.values_list('accounts', 'actions')
for account_names, actions in account_names_actions:
for account_name in account_names:

2
apps/perms/utils/user_permission.py

@ -647,7 +647,7 @@ class UserGrantedNodesQueryUtils(UserGrantedUtilsBase):
def get_whole_tree_nodes(self, with_special=True):
"""
这里的 granted nodes, 是整棵树需要的node推算出来的也算
:param user:
:param with_special:
:return:
"""
nodes = PermNode.objects.filter(

Loading…
Cancel
Save