diff --git a/apps/assets/models/node.py b/apps/assets/models/node.py index 8f6ee45f3..32bfcaa09 100644 --- a/apps/assets/models/node.py +++ b/apps/assets/models/node.py @@ -489,7 +489,7 @@ class SomeNodesMixin: return cls.default_node() if ori_org and ori_org.is_root(): - return None + return cls.default_node() org_roots = cls.org_root_nodes() org_roots_length = len(org_roots) diff --git a/apps/perms/utils/account.py b/apps/perms/utils/account.py index 16e8bb344..b66b247d8 100644 --- a/apps/perms/utils/account.py +++ b/apps/perms/utils/account.py @@ -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): """ 获取授权给用户某个资产的账号 """ diff --git a/apps/rbac/permissions.py b/apps/rbac/permissions.py index 7cc35d370..7c3f21610 100644 --- a/apps/rbac/permissions.py +++ b/apps/rbac/permissions.py @@ -97,13 +97,13 @@ class RBACPermission(permissions.DjangoModelPermissions): else: model_cls = queryset.model except AssertionError as e: - logger.error(f'Error get model cls: {e}') + # logger.error(f'Error get model cls: {e}') model_cls = None except AttributeError as e: - logger.error(f'Error get model cls: {e}') + # logger.error(f'Error get model cls: {e}') model_cls = None except Exception as e: - logger.error('Error get model class: {} of {}'.format(e, view)) + # logger.error('Error get model class: {} of {}'.format(e, view)) raise e return model_cls