fix(perms): 修复asset permission导入的bug

pull/4833/head
ibuler 2020-10-20 14:15:29 +08:00 committed by Jiangjie.Bai
parent f84b845385
commit de405be753
2 changed files with 7 additions and 5 deletions

View File

@ -3,7 +3,7 @@
from django.db.models import Q
from common.permissions import IsOrgAdmin
from orgs.mixins.api import OrgModelViewSet
from orgs.mixins.api import OrgBulkModelViewSet
from common.utils import get_object_or_none
from ..models import AssetPermission
from ..hands import (
@ -17,7 +17,7 @@ __all__ = [
]
class AssetPermissionViewSet(OrgModelViewSet):
class AssetPermissionViewSet(OrgBulkModelViewSet):
"""
资产授权列表的增删改查api
"""

View File

@ -43,12 +43,14 @@ class AssetPermissionSerializer(BulkOrgResourceModelSerializer):
model = AssetPermission
mini_fields = ['id', 'name']
small_fields = mini_fields + [
'is_active', 'is_expired', 'is_valid', 'actions', 'created_by', 'date_created',
'date_expired', 'date_start', 'comment'
'is_active', 'is_expired', 'is_valid', 'actions',
'created_by', 'date_created', 'date_expired',
'date_start', 'comment'
]
m2m_fields = [
'users', 'user_groups', 'assets', 'nodes', 'system_users',
'users_amount', 'user_groups_amount', 'assets_amount', 'nodes_amount', 'system_users_amount',
'users_amount', 'user_groups_amount', 'assets_amount',
'nodes_amount', 'system_users_amount',
]
fields = small_fields + m2m_fields
read_only_fields = ['created_by', 'date_created']