Merge pull request #333 from jangsutsr/7505_disallow_changing_credential_type_of_credential

Disallow changing credential_type of an existing credential
This commit is contained in:
Aaron Tan
2017-08-31 11:37:43 -04:00
committed by GitHub
3 changed files with 36 additions and 1 deletions

View File

@@ -2143,6 +2143,14 @@ class CredentialSerializer(BaseSerializer):
return value
return super(CredentialSerializer, self).to_internal_value(data)
def validate_credential_type(self, credential_type):
if self.instance and credential_type.pk != self.instance.credential_type.pk:
raise ValidationError(
_('You cannot change the credential type of the credential, as it may break the functionality'
' of the resources using it.'),
)
return credential_type
class CredentialSerializerCreate(CredentialSerializer):