perf(project): 优化命名的风格 (#5693)

perf: 修改错误的地

perf: 优化写错的几个

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot
2021-03-08 10:08:51 +08:00
committed by GitHub
parent 935947c97a
commit 0aa2c2016f
40 changed files with 272 additions and 273 deletions

View File

@@ -10,7 +10,7 @@ from rest_framework.generics import (
)
from orgs.utils import tmp_to_root_org
from perms.utils.asset.permission import get_asset_system_users_id_with_actions_by_user
from perms.utils.asset.permission import get_asset_system_user_ids_with_actions_by_user
from common.permissions import IsOrgAdminOrAppUser, IsOrgAdmin, IsValidUser
from common.utils import get_logger, lazyproperty
@@ -53,7 +53,7 @@ class GetUserAssetPermissionActionsApi(RetrieveAPIView):
asset = get_object_or_404(Asset, id=asset_id)
system_user = get_object_or_404(SystemUser, id=system_id)
system_users_actions = get_asset_system_users_id_with_actions_by_user(self.get_user(), asset)
system_users_actions = get_asset_system_user_ids_with_actions_by_user(self.get_user(), asset)
actions = system_users_actions.get(system_user.id)
return {"actions": actions}
@@ -84,7 +84,7 @@ class ValidateUserAssetPermissionApi(APIView):
asset = get_object_or_404(Asset, id=asset_id)
system_user = get_object_or_404(SystemUser, id=system_id)
system_users_actions = get_asset_system_users_id_with_actions_by_user(self.get_user(), asset)
system_users_actions = get_asset_system_user_ids_with_actions_by_user(self.get_user(), asset)
actions = system_users_actions.get(system_user.id)
if actions is None:
return Response({'msg': False}, status=403)
@@ -111,15 +111,15 @@ class UserGrantedAssetSystemUsersForAdminApi(ListAPIView):
user_id = self.kwargs.get('pk')
return User.objects.get(id=user_id)
def get_asset_system_users_id_with_actions(self, asset):
return get_asset_system_users_id_with_actions_by_user(self.user, asset)
def get_asset_system_user_ids_with_actions(self, asset):
return get_asset_system_user_ids_with_actions_by_user(self.user, asset)
def get_queryset(self):
asset_id = self.kwargs.get('asset_id')
asset = get_object_or_404(Asset, id=asset_id)
system_users_with_actions = self.get_asset_system_users_id_with_actions(asset)
system_users_id = system_users_with_actions.keys()
system_users = SystemUser.objects.filter(id__in=system_users_id)\
system_users_with_actions = self.get_asset_system_user_ids_with_actions(asset)
system_user_ids = system_users_with_actions.keys()
system_users = SystemUser.objects.filter(id__in=system_user_ids)\
.only(*self.serializer_class.Meta.only_fields) \
.order_by('priority')
system_users = list(system_users)