Merge branch 'master' into fix-credential_id

Conflicts:
	awx/api/views.py
This commit is contained in:
Chris Meyers
2015-04-27 14:57:53 -04:00
17 changed files with 257 additions and 158 deletions

View File

@@ -1295,6 +1295,16 @@ class CredentialSerializer(BaseSerializer):
for field in Credential.PASSWORD_FIELDS:
if unicode(attrs.get(field, '')).startswith('$encrypted$'):
attrs.pop(field, None)
# If creating a credential from a view that automatically sets the
# parent_key (user or team), set the other value to None.
view = self.context.get('view', None)
parent_key = getattr(view, 'parent_key', None)
if parent_key == 'user':
attrs['team'] = None
if parent_key == 'team':
attrs['user'] = None
instance = super(CredentialSerializer, self).restore_object(attrs, instance)
return instance