fix: 授权资产列表 platform 应该显示名称

pull/5953/head^2
xinwen 2021-04-07 18:20:54 +08:00
parent 32e2d19553
commit 8da4027e32
2 changed files with 4 additions and 3 deletions

View File

@ -23,4 +23,3 @@ urlpatterns = [
]
urlpatterns += router.urls

View File

@ -4,7 +4,7 @@
from rest_framework import serializers
from django.utils.translation import ugettext_lazy as _
from assets.models import Node, SystemUser, Asset
from assets.models import Node, SystemUser, Asset, Platform
from assets.serializers import ProtocolsField
from perms.serializers.asset.permission import ActionsField
@ -39,7 +39,9 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
被授权资产的数据结构
"""
protocols = ProtocolsField(label=_('Protocols'), required=False, read_only=True)
platform = serializers.ReadOnlyField(source='platform_base')
platform = serializers.SlugRelatedField(
slug_field='name', queryset=Platform.objects.all(), label=_("Platform")
)
class Meta:
model = Asset