mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-19 01:45:27 +00:00
perf: perm account 返回 alias
This commit is contained in:
@@ -6,14 +6,10 @@ from django.db.models import Q
|
||||
from rest_framework.generics import ListAPIView
|
||||
from rest_framework.response import Response
|
||||
|
||||
from common.utils import lazyproperty
|
||||
from perms.models import AssetPermission
|
||||
from assets.models import Asset, Node
|
||||
from . import user_permission as uapi
|
||||
from perms import serializers
|
||||
from perms.utils import PermAccountUtil
|
||||
from assets.api.mixin import SerializeToTreeNodeMixin
|
||||
from users.models import UserGroup
|
||||
from assets.models import Asset, Node
|
||||
from perms import serializers
|
||||
from perms.models import AssetPermission
|
||||
|
||||
__all__ = [
|
||||
'UserGroupGrantedAssetsApi', 'UserGroupGrantedNodesApi',
|
||||
@@ -101,11 +97,11 @@ class UserGroupGrantedNodeAssetsApi(ListAPIView):
|
||||
granted_node_q |= Q(nodes__key=_key)
|
||||
|
||||
granted_asset_q = (
|
||||
Q(granted_by_permissions__id__in=asset_perm_ids) &
|
||||
(
|
||||
Q(nodes__key__startswith=f'{node.key}:') |
|
||||
Q(nodes__key=node.key)
|
||||
)
|
||||
Q(granted_by_permissions__id__in=asset_perm_ids) &
|
||||
(
|
||||
Q(nodes__key__startswith=f'{node.key}:') |
|
||||
Q(nodes__key=node.key)
|
||||
)
|
||||
)
|
||||
|
||||
assets = Asset.objects.filter(
|
||||
@@ -115,7 +111,7 @@ class UserGroupGrantedNodeAssetsApi(ListAPIView):
|
||||
|
||||
|
||||
class UserGroupGrantedNodesApi(ListAPIView):
|
||||
serializer_class = serializers.NodeGrantedSerializer
|
||||
serializer_class = serializers.NodePermedSerializer
|
||||
rbac_perms = {
|
||||
'list': 'perms.view_usergroupassets',
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
import abc
|
||||
|
||||
from rest_framework.generics import ListAPIView
|
||||
|
||||
from assets.models import Node
|
||||
from common.utils import get_logger, lazyproperty
|
||||
from perms import serializers
|
||||
from perms.utils.user_permission import UserGrantedNodesQueryUtils
|
||||
from common.utils import get_logger, lazyproperty
|
||||
|
||||
from .mixin import SelfOrPKUserMixin
|
||||
|
||||
logger = get_logger(__name__)
|
||||
@@ -19,7 +19,7 @@ __all__ = [
|
||||
|
||||
|
||||
class BaseUserPermedNodesApi(SelfOrPKUserMixin, ListAPIView):
|
||||
serializer_class = serializers.NodeGrantedSerializer
|
||||
serializer_class = serializers.NodePermedSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
if getattr(self, 'swagger_fake_view', False):
|
||||
@@ -37,12 +37,14 @@ class BaseUserPermedNodesApi(SelfOrPKUserMixin, ListAPIView):
|
||||
|
||||
class UserAllPermedNodesApi(BaseUserPermedNodesApi):
|
||||
""" 用户授权的节点 """
|
||||
|
||||
def get_nodes(self):
|
||||
return self.query_node_util.get_whole_tree_nodes()
|
||||
|
||||
|
||||
class UserPermedNodeChildrenApi(BaseUserPermedNodesApi):
|
||||
""" 用户授权的节点下的子节点 """
|
||||
|
||||
def get_nodes(self):
|
||||
key = self.request.query_params.get('key')
|
||||
nodes = self.query_node_util.get_node_children(key)
|
||||
|
Reference in New Issue
Block a user