mirror of https://github.com/jumpserver/jumpserver
parent
eba43f6a13
commit
c861f390c7
|
@ -118,7 +118,7 @@ class KubernetesTree:
|
|||
|
||||
def as_account_tree_node(self, account, parent_info):
|
||||
username = account.username
|
||||
name = f'{account.name}({account.username})'
|
||||
name = str(account)
|
||||
pid = urlencode({'asset_id': self.tree_id})
|
||||
i = self.create_tree_id(pid, 'account', username)
|
||||
parent_info.update({'account': username})
|
||||
|
|
|
@ -8,7 +8,7 @@ from rest_framework.request import Request
|
|||
from rest_framework.response import Response
|
||||
from rest_framework.generics import get_object_or_404
|
||||
|
||||
from assets.models import Asset
|
||||
from assets.models import Asset, Account
|
||||
from assets.utils import KubernetesTree
|
||||
from assets.api import SerializeToTreeNodeMixin
|
||||
from perms.hands import Node
|
||||
|
@ -141,12 +141,19 @@ class UserGrantedK8sAsTreeApi(
|
|||
asset = get_object_or_404(Asset, **kwargs)
|
||||
return asset
|
||||
|
||||
def get_accounts(self, asset):
|
||||
util = PermAccountUtil()
|
||||
accounts = util.get_permed_accounts_for_user(self.user, asset)
|
||||
ignore_username = [Account.AliasAccount.INPUT, Account.AliasAccount.USER]
|
||||
accounts = filter(lambda x: x.username not in ignore_username, accounts)
|
||||
accounts = list(accounts)
|
||||
return accounts
|
||||
|
||||
def list(self, request: Request, *args, **kwargs):
|
||||
tree_id = request.query_params.get('tree_id')
|
||||
key = request.query_params.get('key', {})
|
||||
|
||||
tree = []
|
||||
util = PermAccountUtil()
|
||||
parent_info = dict(parse_qsl(key))
|
||||
account_username = parent_info.get('account')
|
||||
|
||||
|
@ -155,7 +162,7 @@ class UserGrantedK8sAsTreeApi(
|
|||
|
||||
if tree_id and not account_username:
|
||||
asset = self.asset(asset_id)
|
||||
accounts = util.get_permed_accounts_for_user(self.user, asset)
|
||||
accounts = self.get_accounts(asset)
|
||||
asset_node = KubernetesTree(tree_id).as_asset_tree_node(asset)
|
||||
tree.append(asset_node)
|
||||
for account in accounts:
|
||||
|
|
Loading…
Reference in New Issue