mirror of https://github.com/jumpserver/jumpserver
fix: 修复获取用户收藏的资产API失败的问题
parent
0dec61368c
commit
896b59b1bd
|
@ -15,7 +15,7 @@ from ...const import Category, AllTypes
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'AssetSerializer', 'AssetSimpleSerializer', 'MiniAssetSerializer',
|
'AssetSerializer', 'AssetSimpleSerializer', 'MiniAssetSerializer',
|
||||||
'AssetTaskSerializer', 'AssetsTaskSerializer',
|
'AssetTaskSerializer', 'AssetsTaskSerializer', 'AssetProtocolsSerializer',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from assets.const import Category, AllTypes
|
from assets.const import Category, AllTypes
|
||||||
|
from assets.serializers.asset.common import AssetProtocolsSerializer
|
||||||
from assets.models import Node, Asset, Platform, Account
|
from assets.models import Node, Asset, Platform, Account
|
||||||
from common.drf.fields import ObjectRelatedField, LabeledChoiceField
|
from common.drf.fields import ObjectRelatedField, LabeledChoiceField
|
||||||
from perms.serializers.permission import ActionChoicesField
|
from perms.serializers.permission import ActionChoicesField
|
||||||
|
@ -17,17 +18,15 @@ __all__ = [
|
||||||
|
|
||||||
class AssetGrantedSerializer(serializers.ModelSerializer):
|
class AssetGrantedSerializer(serializers.ModelSerializer):
|
||||||
""" 被授权资产的数据结构 """
|
""" 被授权资产的数据结构 """
|
||||||
platform = serializers.SlugRelatedField(
|
platform = ObjectRelatedField(required=False, queryset=Platform.objects, label=_('Platform'))
|
||||||
slug_field='name', queryset=Platform.objects.all(), label=_("Platform")
|
protocols = AssetProtocolsSerializer(many=True, required=False, label=_('Protocols'))
|
||||||
)
|
|
||||||
protocols = ObjectRelatedField(read_only=True, many=True)
|
|
||||||
category = LabeledChoiceField(choices=Category.choices, read_only=True, label=_('Category'))
|
category = LabeledChoiceField(choices=Category.choices, read_only=True, label=_('Category'))
|
||||||
type = LabeledChoiceField(choices=AllTypes.choices(), read_only=True, label=_('Type'))
|
type = LabeledChoiceField(choices=AllTypes.choices(), read_only=True, label=_('Type'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Asset
|
model = Asset
|
||||||
only_fields = [
|
only_fields = [
|
||||||
"id", "name", "address", "protocols",
|
"id", "name", "address",
|
||||||
'domain', 'platform',
|
'domain', 'platform',
|
||||||
"comment", "org_id", "is_active",
|
"comment", "org_id", "is_active",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue