mirror of
https://github.com/ansible/awx.git
synced 2026-05-03 23:55:28 -02:30
fix a bug for "users should be able to change type of unused credential"
see: https://github.com/ansible/ansible-tower/issues/7516 related: https://github.com/ansible/tower/pull/441
This commit is contained in:
@@ -2192,6 +2192,19 @@ class CredentialSerializer(BaseSerializer):
|
||||
_('You cannot change the credential type of the credential, as it may break the functionality'
|
||||
' of the resources using it.'),
|
||||
)
|
||||
|
||||
# TODO: When this code lands in awx, these relationships won't exist
|
||||
# anymore, so we need to remove this code and make sure the related
|
||||
# tests still pass.
|
||||
for cls in (JobTemplate, Job):
|
||||
for rel in ('extra_credentials__id', 'vault_credential_id'):
|
||||
if cls.objects.filter(**{
|
||||
rel: self.instance.pk
|
||||
}).count() > 0:
|
||||
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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user