Browse Source

fix: 修复remoteapp获取asset_info失败的问题

pull/6127/head
Bai 4 years ago committed by Jiangjie.Bai
parent
commit
70055b8af2
  1. 6
      apps/applications/serializers/attrs/application_category/remote_app.py

6
apps/applications/serializers/attrs/application_category/remote_app.py

@ -39,14 +39,14 @@ class RemoteAppSerializer(serializers.Serializer):
@staticmethod
def get_asset_info(obj):
asset_id = obj.get('asset')
if not asset_id or is_uuid(asset_id):
if not asset_id or not is_uuid(asset_id):
return {}
try:
asset = Asset.objects.filter(id=str(asset_id)).values_list('id', 'hostname')
asset = Asset.objects.get(id=str(asset_id))
except ObjectDoesNotExist as e:
logger.error(e)
return {}
if not asset:
return {}
asset_info = {'id': str(asset[0]), 'hostname': asset[1]}
asset_info = {'id': str(asset.id), 'hostname': asset.hostname}
return asset_info

Loading…
Cancel
Save