perf: perm user asset add labels (#10339)

Co-authored-by: feng <1304903146@qq.com>
pull/10347/head
fit2bot 2 years ago committed by GitHub
parent 8fe5ab42e8
commit a19586f8b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,7 @@ __all__ = [
'AssetSerializer', 'AssetSimpleSerializer', 'MiniAssetSerializer',
'AssetTaskSerializer', 'AssetsTaskSerializer', 'AssetProtocolsSerializer',
'AssetDetailSerializer', 'DetailMixin', 'AssetAccountSerializer',
'AccountSecretSerializer', 'AssetProtocolsPermsSerializer'
'AccountSecretSerializer', 'AssetProtocolsPermsSerializer', 'AssetLabelSerializer'
]

@ -8,7 +8,7 @@ from rest_framework import serializers
from accounts.models import Account
from assets.const import Category, AllTypes
from assets.models import Node, Asset, Platform
from assets.serializers.asset.common import AssetProtocolsPermsSerializer
from assets.serializers.asset.common import AssetProtocolsPermsSerializer, AssetLabelSerializer
from common.serializers.fields import ObjectRelatedField, LabeledChoiceField
from orgs.mixins.serializers import OrgResourceModelSerializerMixin
from perms.serializers.permission import ActionChoicesField
@ -25,6 +25,7 @@ class AssetPermedSerializer(OrgResourceModelSerializerMixin):
protocols = AssetProtocolsPermsSerializer(many=True, required=False, label=_('Protocols'))
category = LabeledChoiceField(choices=Category.choices, read_only=True, label=_('Category'))
type = LabeledChoiceField(choices=AllTypes.choices(), read_only=True, label=_('Type'))
labels = AssetLabelSerializer(many=True, required=False, label=_('Label'))
domain = ObjectRelatedField(required=False, queryset=Node.objects, label=_('Domain'))
class Meta:
@ -32,7 +33,7 @@ class AssetPermedSerializer(OrgResourceModelSerializerMixin):
only_fields = [
'id', 'name', 'address', 'domain', 'platform',
'comment', 'org_id', 'is_active', 'date_verified',
'created_by', 'date_created', 'connectivity', 'nodes'
'created_by', 'date_created', 'connectivity', 'nodes', 'labels'
]
fields = only_fields + ['protocols', 'category', 'type'] + ['org_name']
read_only_fields = fields

Loading…
Cancel
Save