fix: 修复remote app没有返回asset的bug

This commit is contained in:
ibuler
2021-08-17 11:06:16 +08:00
committed by Jiangjie.Bai
parent 7d7da9bf98
commit dba416f5eb
2 changed files with 5 additions and 5 deletions

View File

@@ -14,7 +14,7 @@ logger = get_logger(__file__)
__all__ = ['RemoteAppSerializer']
class AssetCharPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField):
class ExistAssetPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField):
def to_internal_value(self, data):
instance = super().to_internal_value(data)
@@ -26,14 +26,14 @@ class AssetCharPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField):
return self.pk_field.to_representation(_id)
# 解决删除资产后远程应用更新页面会显示资产ID的问题
asset = get_object_or_none(Asset, id=_id)
if asset:
if not asset:
return None
return _id
class RemoteAppSerializer(serializers.Serializer):
asset_info = serializers.SerializerMethodField()
asset = AssetCharPrimaryKeyRelatedField(
asset = ExistAssetPrimaryKeyRelatedField(
queryset=Asset.objects, required=False, label=_("Asset"), allow_null=True
)
path = serializers.CharField(