Disallow changing credential_type of an existing credential

This commit is contained in:
Aaron Tan
2017-08-24 15:48:53 -04:00
parent 3b2149f252
commit 276bed2d0b
3 changed files with 36 additions and 1 deletions

View File

@@ -2141,6 +2141,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):