Skip to content

Commit

Permalink
fix a bug introduced in the inventory source detail API by v1 removal
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpetrello committed Jun 13, 2019
1 parent e1d60ff commit ae9032c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,25 @@ def validate(self, attrs):

return super(InventorySourceOptionsSerializer, self).validate(attrs)

# TODO: remove when old 'credential' fields are removed
def get_summary_fields(self, obj):
summary_fields = super(InventorySourceOptionsSerializer, self).get_summary_fields(obj)
all_creds = []
if 'credential' in summary_fields:
cred = obj.get_cloud_credential()
if cred:
summarized_cred = {
'id': cred.id, 'name': cred.name, 'description': cred.description,
'kind': cred.kind, 'cloud': True
}
summary_fields['credential'] = summarized_cred
all_creds.append(summarized_cred)
summary_fields['credential']['credential_type_id'] = cred.credential_type_id
else:
summary_fields.pop('credential')
summary_fields['credentials'] = all_creds
return summary_fields


class InventorySourceSerializer(UnifiedJobTemplateSerializer, InventorySourceOptionsSerializer):

Expand Down

0 comments on commit ae9032c

Please sign in to comment.