Commit 3681bfc0 authored by ibuler's avatar ibuler

[Update] 修改用户组授权api

parent 82b00008
...@@ -8,14 +8,14 @@ from assets.utils import LabelFilterMixin ...@@ -8,14 +8,14 @@ from assets.utils import LabelFilterMixin
from common.permissions import IsValidUser, IsOrgAdminOrAppUser from common.permissions import IsValidUser, IsOrgAdminOrAppUser
from common.utils import get_logger from common.utils import get_logger
from orgs.utils import set_to_root_org from orgs.utils import set_to_root_org
from ..hands import User, Asset, SystemUser from ..hands import User, UserGroup, Asset, SystemUser
from .. import serializers from .. import serializers
logger = get_logger(__name__) logger = get_logger(__name__)
__all__ = [ __all__ = [
'UserPermissionMixin', 'UserPermissionMixin', 'UserGroupPermissionMixin',
] ]
...@@ -45,6 +45,15 @@ class UserPermissionMixin: ...@@ -45,6 +45,15 @@ class UserPermissionMixin:
return super().get_permissions() 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): class GrantAssetsMixin(LabelFilterMixin):
serializer_class = serializers.AssetGrantedSerializer serializer_class = serializers.AssetGrantedSerializer
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
from django.shortcuts import get_object_or_404
from ..hands import UserGroup
from . import user_permission as uapi from . import user_permission as uapi
from .mixin import UserGroupPermissionMixin
__all__ = [ __all__ = [
'UserGroupGrantedAssetsApi', 'UserGroupGrantedNodesApi', 'UserGroupGrantedAssetsApi', 'UserGroupGrantedNodesApi',
...@@ -17,15 +15,6 @@ __all__ = [ ...@@ -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): class UserGroupGrantedAssetsApi(UserGroupPermissionMixin, uapi.UserGrantedAssetsApi):
pass pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment