fix a 500 error in /api/v1/credentials/ backwards compat

see: #6414
This commit is contained in:
Ryan Petrello
2017-06-01 11:22:27 -04:00
parent e7d1e2d3a4
commit fd4b86349c
2 changed files with 18 additions and 0 deletions

View File

@@ -2045,6 +2045,8 @@ class CredentialSerializer(BaseSerializer):
# CredentialType based on the provided values
kind = data.get('kind', 'ssh')
credential_type = CredentialType.from_v1_kind(kind, data)
if credential_type is None:
raise serializers.ValidationError({"kind": _('"%s" is not a valid choice' % kind)})
data['credential_type'] = credential_type.pk
value = OrderedDict(
{'credential_type': credential_type}.items() +