mirror of https://github.com/jumpserver/jumpserver
fix: 授权 API 顺序整理
parent
ca6b8ee960
commit
da772b572a
|
@ -40,8 +40,7 @@ class AssetPermissionUserRelationViewSet(RelationMixin):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset \
|
||||
.annotate(user_display=F('user__name'))
|
||||
queryset = queryset.annotate(user_display=F('user__name'))
|
||||
return queryset
|
||||
|
||||
|
||||
|
@ -69,8 +68,7 @@ class AssetPermissionUserGroupRelationViewSet(RelationMixin):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset \
|
||||
.annotate(usergroup_display=F('usergroup__name'))
|
||||
queryset = queryset.annotate(usergroup_display=F('usergroup__name'))
|
||||
return queryset
|
||||
|
||||
|
||||
|
@ -84,8 +82,7 @@ class AssetPermissionAssetRelationViewSet(RelationMixin):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset \
|
||||
.annotate(asset_display=F('asset__name'))
|
||||
queryset = queryset.annotate(asset_display=F('asset__name'))
|
||||
return queryset
|
||||
|
||||
|
||||
|
@ -111,7 +108,6 @@ class AssetPermissionNodeRelationViewSet(RelationMixin):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset \
|
||||
.annotate(node_key=F('node__key'))
|
||||
queryset = queryset.annotate(node_key=F('node__key'))
|
||||
return queryset
|
||||
|
||||
|
|
|
@ -32,15 +32,15 @@ class UserDirectGrantedAssetsQuerysetMixin:
|
|||
class UserAllGrantedAssetsQuerysetMixin:
|
||||
only_fields = serializers.AssetGrantedSerializer.Meta.only_fields
|
||||
pagination_class = AllGrantedAssetPagination
|
||||
user: User
|
||||
ordering_fields = ("hostname", "ip", "port", "cpu_cores")
|
||||
ordering = ('hostname', )
|
||||
|
||||
|
||||
user: User
|
||||
|
||||
def get_queryset(self):
|
||||
if getattr(self, 'swagger_fake_view', False):
|
||||
return Asset.objects.none()
|
||||
queryset = UserGrantedAssetsQueryUtils(self.user) \
|
||||
.get_all_granted_assets()
|
||||
queryset = UserGrantedAssetsQueryUtils(self.user).get_all_granted_assets()
|
||||
queryset = queryset.prefetch_related('platform').only(*self.only_fields)
|
||||
return queryset
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from rest_framework_bulk.routes import BulkRouter
|
|||
|
||||
from .. import api
|
||||
|
||||
# v3 Done
|
||||
router = BulkRouter()
|
||||
router.register('asset-permissions', api.AssetPermissionViewSet, 'asset-permission')
|
||||
router.register('asset-permissions-users-relations', api.AssetPermissionUserRelationViewSet, 'asset-permissions-users-relation')
|
||||
|
@ -86,6 +87,8 @@ user_group_permission_urlpatterns = [
|
|||
]
|
||||
|
||||
permission_urlpatterns = [
|
||||
# Todo: 获取规则中授权的所有账号列表
|
||||
#
|
||||
# 授权规则中授权的资产
|
||||
path('<uuid:pk>/assets/all/', api.AssetPermissionAllAssetListApi.as_view(), name='asset-permission-all-assets'),
|
||||
path('<uuid:pk>/users/all/', api.AssetPermissionAllUserListApi.as_view(), name='asset-permission-all-users'),
|
||||
|
|
Loading…
Reference in New Issue