Skip to content

Commit

Permalink
fix: 修改授权权限
Browse files Browse the repository at this point in the history
  • Loading branch information
feng626 authored and BaiJiangJie committed Mar 15, 2022
1 parent 7ba19ab commit c41a81c
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions apps/perms/api/application/user_permission/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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

Expand Down Expand Up @@ -45,11 +45,11 @@ def get_queryset(self):
return system_users


class UserGrantedApplicationSystemUsersApi(RoleAdminMixin, BaseGrantedApplicationSystemUsersApi):
class UserGrantedApplicationSystemUsersApi(AppRoleAdminMixin, BaseGrantedApplicationSystemUsersApi):
pass


class MyGrantedApplicationSystemUsersApi(RoleUserMixin, BaseGrantedApplicationSystemUsersApi):
class MyGrantedApplicationSystemUsersApi(AppRoleUserMixin, BaseGrantedApplicationSystemUsersApi):
pass


Expand Down
4 changes: 2 additions & 2 deletions apps/perms/api/application/user_permission/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from orgs.utils import tmp_to_root_org


class RoleAdminMixin(_RoleAdminMixin):
class AppRoleAdminMixin(_RoleAdminMixin):
rbac_perms = (
('list', 'perms.view_userapp'),
('retrieve', 'perms.view_userapps'),
Expand All @@ -15,7 +15,7 @@ class RoleAdminMixin(_RoleAdminMixin):
)


class RoleUserMixin(_RoleUserMixin):
class AppRoleUserMixin(_RoleUserMixin):
rbac_perms = (
('list', 'perms.view_myapps'),
('retrieve', 'perms.view_myapps'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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
)
Expand Down Expand Up @@ -41,11 +41,11 @@ def get_queryset(self):
return queryset.only(*self.only_fields)


class UserAllGrantedApplicationsApi(RoleAdminMixin, AllGrantedApplicationsMixin):
class UserAllGrantedApplicationsApi(AppRoleAdminMixin, AllGrantedApplicationsMixin):
pass


class MyAllGrantedApplicationsApi(RoleUserMixin, AllGrantedApplicationsMixin):
class MyAllGrantedApplicationsApi(AppRoleUserMixin, AllGrantedApplicationsMixin):
pass


Expand Down
4 changes: 2 additions & 2 deletions apps/perms/api/asset/user_permission/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, request: Request, *args, **kwargs):
return super().get(request, *args, **kwargs)


class RoleAdminMixin(PermBaseMixin, _RoleAdminMixin):
class AssetRoleAdminMixin(PermBaseMixin, _RoleAdminMixin):
rbac_perms = (
('list', 'perms.view_userassets'),
('retrieve', 'perms.view_userassets'),
Expand All @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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,
Expand All @@ -19,42 +19,42 @@


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):
Expand All @@ -65,34 +65,34 @@ def get_queryset(self):


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):
Expand Down
16 changes: 8 additions & 8 deletions apps/perms/api/asset/user_permission/user_permission_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

Expand Down Expand Up @@ -100,33 +100,33 @@ def get_nodes(self):

# ------------------------------------------
# 最终的 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

# ------------------------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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,
Expand Down Expand Up @@ -146,9 +146,9 @@ def list(self, request: Request, *args, **kwargs):
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

0 comments on commit c41a81c

Please sign in to comment.