From c41a81c8d01065ecf586b1d239f2f23c909daace Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Tue, 15 Mar 2022 10:52:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/application/user_permission/common.py | 6 ++--- .../api/application/user_permission/mixin.py | 4 ++-- .../user_permission_applications.py | 6 ++--- apps/perms/api/asset/user_permission/mixin.py | 4 ++-- .../user_permission_assets/views.py | 24 +++++++++---------- .../user_permission/user_permission_nodes.py | 16 ++++++------- .../user_permission_nodes_with_assets.py | 6 ++--- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/apps/perms/api/application/user_permission/common.py b/apps/perms/api/application/user_permission/common.py index f24718560..34fcc4dd1 100644 --- a/apps/perms/api/application/user_permission/common.py +++ b/apps/perms/api/application/user_permission/common.py @@ -16,7 +16,7 @@ from perms.utils.application.permission import ( get_application_system_user_ids, validate_permission, ) -from .mixin import RoleAdminMixin, RoleUserMixin +from .mixin import AppRoleAdminMixin, AppRoleUserMixin from perms.hands import User, SystemUser from perms import serializers @@ -45,11 +45,11 @@ class BaseGrantedApplicationSystemUsersApi(ListAPIView): return system_users -class UserGrantedApplicationSystemUsersApi(RoleAdminMixin, BaseGrantedApplicationSystemUsersApi): +class UserGrantedApplicationSystemUsersApi(AppRoleAdminMixin, BaseGrantedApplicationSystemUsersApi): pass -class MyGrantedApplicationSystemUsersApi(RoleUserMixin, BaseGrantedApplicationSystemUsersApi): +class MyGrantedApplicationSystemUsersApi(AppRoleUserMixin, BaseGrantedApplicationSystemUsersApi): pass diff --git a/apps/perms/api/application/user_permission/mixin.py b/apps/perms/api/application/user_permission/mixin.py index 9f2becb34..b66788c31 100644 --- a/apps/perms/api/application/user_permission/mixin.py +++ b/apps/perms/api/application/user_permission/mixin.py @@ -6,7 +6,7 @@ from common.mixins.api import RoleUserMixin as _RoleUserMixin from orgs.utils import tmp_to_root_org -class RoleAdminMixin(_RoleAdminMixin): +class AppRoleAdminMixin(_RoleAdminMixin): rbac_perms = ( ('list', 'perms.view_userapp'), ('retrieve', 'perms.view_userapps'), @@ -15,7 +15,7 @@ class RoleAdminMixin(_RoleAdminMixin): ) -class RoleUserMixin(_RoleUserMixin): +class AppRoleUserMixin(_RoleUserMixin): rbac_perms = ( ('list', 'perms.view_myapps'), ('retrieve', 'perms.view_myapps'), diff --git a/apps/perms/api/application/user_permission/user_permission_applications.py b/apps/perms/api/application/user_permission/user_permission_applications.py index b9ddf1850..f1f5e0e66 100644 --- a/apps/perms/api/application/user_permission/user_permission_applications.py +++ b/apps/perms/api/application/user_permission/user_permission_applications.py @@ -9,7 +9,7 @@ from applications.api.mixin import ( SerializeApplicationToTreeNodeMixin ) from perms import serializers -from perms.api.asset.user_permission.mixin import RoleAdminMixin, RoleUserMixin +from .mixin import AppRoleAdminMixin, AppRoleUserMixin from perms.utils.application.user_permission import ( get_user_granted_all_applications ) @@ -41,11 +41,11 @@ class AllGrantedApplicationsMixin(CommonApiMixin, ListAPIView): return queryset.only(*self.only_fields) -class UserAllGrantedApplicationsApi(RoleAdminMixin, AllGrantedApplicationsMixin): +class UserAllGrantedApplicationsApi(AppRoleAdminMixin, AllGrantedApplicationsMixin): pass -class MyAllGrantedApplicationsApi(RoleUserMixin, AllGrantedApplicationsMixin): +class MyAllGrantedApplicationsApi(AppRoleUserMixin, AllGrantedApplicationsMixin): pass diff --git a/apps/perms/api/asset/user_permission/mixin.py b/apps/perms/api/asset/user_permission/mixin.py index 9514d41b0..e06ec9787 100644 --- a/apps/perms/api/asset/user_permission/mixin.py +++ b/apps/perms/api/asset/user_permission/mixin.py @@ -20,7 +20,7 @@ class PermBaseMixin: return super().get(request, *args, **kwargs) -class RoleAdminMixin(PermBaseMixin, _RoleAdminMixin): +class AssetRoleAdminMixin(PermBaseMixin, _RoleAdminMixin): rbac_perms = ( ('list', 'perms.view_userassets'), ('retrieve', 'perms.view_userassets'), @@ -29,7 +29,7 @@ class RoleAdminMixin(PermBaseMixin, _RoleAdminMixin): ) -class RoleUserMixin(PermBaseMixin, _RoleUserMixin): +class AssetRoleUserMixin(PermBaseMixin, _RoleUserMixin): rbac_perms = ( ('list', 'perms.view_myassets'), ('retrieve', 'perms.view_myassets'), diff --git a/apps/perms/api/asset/user_permission/user_permission_assets/views.py b/apps/perms/api/asset/user_permission/user_permission_assets/views.py index 64ddb0180..da304ee6c 100644 --- a/apps/perms/api/asset/user_permission/user_permission_assets/views.py +++ b/apps/perms/api/asset/user_permission/user_permission_assets/views.py @@ -2,7 +2,7 @@ from rest_framework.generics import ListAPIView from django.conf import settings from common.utils import get_logger -from ..mixin import RoleAdminMixin, RoleUserMixin +from ..mixin import AssetRoleAdminMixin, AssetRoleUserMixin from .mixin import ( UserAllGrantedAssetsQuerysetMixin, UserDirectGrantedAssetsQuerysetMixin, UserFavoriteGrantedAssetsMixin, UserGrantedNodeAssetsMixin, AssetsSerializerFormatMixin, AssetsTreeFormatMixin, @@ -19,42 +19,42 @@ logger = get_logger(__name__) class UserDirectGrantedAssetsForAdminApi(UserDirectGrantedAssetsQuerysetMixin, - RoleAdminMixin, + AssetRoleAdminMixin, AssetsSerializerFormatMixin, ListAPIView): pass class MyDirectGrantedAssetsApi(UserDirectGrantedAssetsQuerysetMixin, - RoleUserMixin, + AssetRoleUserMixin, AssetsSerializerFormatMixin, ListAPIView): pass class UserFavoriteGrantedAssetsForAdminApi(UserFavoriteGrantedAssetsMixin, - RoleAdminMixin, + AssetRoleAdminMixin, AssetsSerializerFormatMixin, ListAPIView): pass class MyFavoriteGrantedAssetsApi(UserFavoriteGrantedAssetsMixin, - RoleUserMixin, + AssetRoleUserMixin, AssetsSerializerFormatMixin, ListAPIView): pass class UserDirectGrantedAssetsAsTreeForAdminApi(UserDirectGrantedAssetsQuerysetMixin, - RoleAdminMixin, + AssetRoleAdminMixin, AssetsTreeFormatMixin, ListAPIView): pass class MyUngroupAssetsAsTreeApi(UserDirectGrantedAssetsQuerysetMixin, - RoleUserMixin, + AssetRoleUserMixin, AssetsTreeFormatMixin, ListAPIView): def get_queryset(self): @@ -65,34 +65,34 @@ class MyUngroupAssetsAsTreeApi(UserDirectGrantedAssetsQuerysetMixin, class UserAllGrantedAssetsApi(UserAllGrantedAssetsQuerysetMixin, - RoleAdminMixin, + AssetRoleAdminMixin, AssetsSerializerFormatMixin, ListAPIView): pass class MyAllGrantedAssetsApi(UserAllGrantedAssetsQuerysetMixin, - RoleUserMixin, + AssetRoleUserMixin, AssetsSerializerFormatMixin, ListAPIView): pass class MyAllAssetsAsTreeApi(UserAllGrantedAssetsQuerysetMixin, - RoleUserMixin, + AssetRoleUserMixin, AssetsTreeFormatMixin, ListAPIView): pass -class UserGrantedNodeAssetsForAdminApi(RoleAdminMixin, +class UserGrantedNodeAssetsForAdminApi(AssetRoleAdminMixin, UserGrantedNodeAssetsMixin, AssetsSerializerFormatMixin, ListAPIView): pass -class MyGrantedNodeAssetsApi(RoleUserMixin, +class MyGrantedNodeAssetsApi(AssetRoleUserMixin, UserGrantedNodeAssetsMixin, AssetsSerializerFormatMixin, ListAPIView): diff --git a/apps/perms/api/asset/user_permission/user_permission_nodes.py b/apps/perms/api/asset/user_permission/user_permission_nodes.py index 558b888c2..e2b8aec71 100644 --- a/apps/perms/api/asset/user_permission/user_permission_nodes.py +++ b/apps/perms/api/asset/user_permission/user_permission_nodes.py @@ -9,7 +9,7 @@ from rest_framework.request import Request from assets.api.mixin import SerializeToTreeNodeMixin from common.utils import get_logger -from .mixin import RoleAdminMixin, RoleUserMixin +from .mixin import AssetRoleAdminMixin, AssetRoleUserMixin from perms.hands import User from perms import serializers @@ -100,33 +100,33 @@ class UserGrantedNodesMixin: # ------------------------------------------ # 最终的 api -class UserGrantedNodeChildrenForAdminApi(RoleAdminMixin, UserGrantedNodeChildrenMixin, BaseNodeChildrenApi): +class UserGrantedNodeChildrenForAdminApi(AssetRoleAdminMixin, UserGrantedNodeChildrenMixin, BaseNodeChildrenApi): pass -class MyGrantedNodeChildrenApi(RoleUserMixin, UserGrantedNodeChildrenMixin, BaseNodeChildrenApi): +class MyGrantedNodeChildrenApi(AssetRoleUserMixin, UserGrantedNodeChildrenMixin, BaseNodeChildrenApi): pass -class UserGrantedNodeChildrenAsTreeForAdminApi(RoleAdminMixin, UserGrantedNodeChildrenMixin, BaseNodeChildrenAsTreeApi): +class UserGrantedNodeChildrenAsTreeForAdminApi(AssetRoleAdminMixin, UserGrantedNodeChildrenMixin, BaseNodeChildrenAsTreeApi): pass -class MyGrantedNodeChildrenAsTreeApi(RoleUserMixin, UserGrantedNodeChildrenMixin, BaseNodeChildrenAsTreeApi): +class MyGrantedNodeChildrenAsTreeApi(AssetRoleUserMixin, UserGrantedNodeChildrenMixin, BaseNodeChildrenAsTreeApi): def get_permissions(self): permissions = super().get_permissions() return permissions -class UserGrantedNodesForAdminApi(RoleAdminMixin, UserGrantedNodesMixin, BaseGrantedNodeApi): +class UserGrantedNodesForAdminApi(AssetRoleAdminMixin, UserGrantedNodesMixin, BaseGrantedNodeApi): pass -class MyGrantedNodesApi(RoleUserMixin, UserGrantedNodesMixin, BaseGrantedNodeApi): +class MyGrantedNodesApi(AssetRoleUserMixin, UserGrantedNodesMixin, BaseGrantedNodeApi): pass -class MyGrantedNodesAsTreeApi(RoleUserMixin, UserGrantedNodesMixin, BaseGrantedNodeAsTreeApi): +class MyGrantedNodesAsTreeApi(AssetRoleUserMixin, UserGrantedNodesMixin, BaseGrantedNodeAsTreeApi): pass # ------------------------------------------ diff --git a/apps/perms/api/asset/user_permission/user_permission_nodes_with_assets.py b/apps/perms/api/asset/user_permission/user_permission_nodes_with_assets.py index f66ed3c3f..d65f08df6 100644 --- a/apps/perms/api/asset/user_permission/user_permission_nodes_with_assets.py +++ b/apps/perms/api/asset/user_permission/user_permission_nodes_with_assets.py @@ -10,7 +10,7 @@ from common.utils.common import timeit from orgs.utils import tmp_to_root_org from common.permissions import IsValidUser from common.utils import get_logger, get_object_or_none -from .mixin import RoleUserMixin, RoleAdminMixin +from .mixin import AssetRoleUserMixin, AssetRoleAdminMixin from perms.utils.asset.user_permission import ( UserGrantedTreeBuildUtils, get_user_all_asset_perm_ids, UserGrantedNodesQueryUtils, UserGrantedAssetsQueryUtils, @@ -146,9 +146,9 @@ class GrantedNodeChildrenWithAssetsAsTreeApiMixin(SerializeToTreeNodeMixin, return Response(data=[*tree_nodes, *tree_assets]) -class UserGrantedNodeChildrenWithAssetsAsTreeApi(RoleAdminMixin, GrantedNodeChildrenWithAssetsAsTreeApiMixin): +class UserGrantedNodeChildrenWithAssetsAsTreeApi(AssetRoleAdminMixin, GrantedNodeChildrenWithAssetsAsTreeApiMixin): pass -class MyGrantedNodeChildrenWithAssetsAsTreeApi(RoleUserMixin, GrantedNodeChildrenWithAssetsAsTreeApiMixin): +class MyGrantedNodeChildrenWithAssetsAsTreeApi(AssetRoleUserMixin, GrantedNodeChildrenWithAssetsAsTreeApiMixin): pass