|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
from collections import defaultdict
|
|
|
|
|
|
|
|
|
|
from orgs.utils import tmp_to_org
|
|
|
|
|
from accounts.models import Account
|
|
|
|
|
from accounts.const import AliasAccount
|
|
|
|
|
from .permission import AssetPermissionUtil
|
|
|
|
@ -16,10 +17,11 @@ class PermAccountUtil(AssetPermissionUtil):
|
|
|
|
|
:param asset: Asset
|
|
|
|
|
:param account_name: 可能是 @USER @INPUT 字符串
|
|
|
|
|
"""
|
|
|
|
|
permed_accounts = self.get_permed_accounts_for_user(user, asset)
|
|
|
|
|
accounts_mapper = {account.alias: account for account in permed_accounts}
|
|
|
|
|
account = accounts_mapper.get(account_name)
|
|
|
|
|
return account
|
|
|
|
|
with tmp_to_org(asset.org):
|
|
|
|
|
permed_accounts = self.get_permed_accounts_for_user(user, asset)
|
|
|
|
|
accounts_mapper = {account.alias: account for account in permed_accounts}
|
|
|
|
|
account = accounts_mapper.get(account_name)
|
|
|
|
|
return account
|
|
|
|
|
|
|
|
|
|
def get_permed_accounts_for_user(self, user, asset):
|
|
|
|
|
""" 获取授权给用户某个资产的账号 """
|
|
|
|
|