mirror of https://github.com/jumpserver/jumpserver
[Update] 修改用户组授权api
parent
82b00008d9
commit
3681bfc015
|
@ -8,14 +8,14 @@ from assets.utils import LabelFilterMixin
|
|||
from common.permissions import IsValidUser, IsOrgAdminOrAppUser
|
||||
from common.utils import get_logger
|
||||
from orgs.utils import set_to_root_org
|
||||
from ..hands import User, Asset, SystemUser
|
||||
from ..hands import User, UserGroup, Asset, SystemUser
|
||||
from .. import serializers
|
||||
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
__all__ = [
|
||||
'UserPermissionMixin',
|
||||
'UserPermissionMixin', 'UserGroupPermissionMixin',
|
||||
]
|
||||
|
||||
|
||||
|
@ -45,6 +45,15 @@ class UserPermissionMixin:
|
|||
return super().get_permissions()
|
||||
|
||||
|
||||
class UserGroupPermissionMixin:
|
||||
obj = None
|
||||
|
||||
def get_obj(self):
|
||||
user_group_id = self.kwargs.get('pk', '')
|
||||
user_group = get_object_or_404(UserGroup, id=user_group_id)
|
||||
return user_group
|
||||
|
||||
|
||||
class GrantAssetsMixin(LabelFilterMixin):
|
||||
serializer_class = serializers.AssetGrantedSerializer
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
from ..hands import UserGroup
|
||||
|
||||
from . import user_permission as uapi
|
||||
from .mixin import UserGroupPermissionMixin
|
||||
|
||||
__all__ = [
|
||||
'UserGroupGrantedAssetsApi', 'UserGroupGrantedNodesApi',
|
||||
|
@ -17,15 +15,6 @@ __all__ = [
|
|||
]
|
||||
|
||||
|
||||
class UserGroupPermissionMixin:
|
||||
obj = None
|
||||
|
||||
def get_object(self):
|
||||
user_group_id = self.kwargs.get('pk', '')
|
||||
user_group = get_object_or_404(UserGroup, id=user_group_id)
|
||||
return user_group
|
||||
|
||||
|
||||
class UserGroupGrantedAssetsApi(UserGroupPermissionMixin, uapi.UserGrantedAssetsApi):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue