fix bug saving extra_data and follow prompts rules

display_extra_vars was not taking a copy of the data before
acting on it - this causes a bug where the activity stream will
modify the existing object on the model. That leads to new data
not being accepted.

Also moved the processing of extra_data to prior to the accept
or ignore kwargs logic so that we pass the right (post-encryption)
form of the variables.
This commit is contained in:
AlanCoding
2017-12-18 09:40:04 -05:00
parent 1e1839915d
commit c8e10adc96
5 changed files with 34 additions and 24 deletions

View File

@@ -14,7 +14,7 @@ from awx.main.models.rbac import (
Role, RoleAncestorEntry, get_roles_on_resource
)
from awx.main.utils import parse_yaml_or_json
from awx.main.utils.encryption import decrypt_value, get_encryption_key
from awx.main.utils.encryption import decrypt_value, get_encryption_key, is_encrypted
from awx.main.fields import JSONField, AskForField
@@ -266,9 +266,10 @@ class SurveyJobTemplateMixin(models.Model):
survey_errors = []
for survey_element in self.survey_spec.get("spec", []):
key = survey_element.get('variable', None)
if extra_passwords and key in extra_passwords and data.get(key, None):
value = data.get(key, None)
if extra_passwords and key in extra_passwords and is_encrypted(value):
element_errors = self._survey_element_validation(survey_element, {
key: decrypt_value(get_encryption_key('value', pk=None), data[key])
key: decrypt_value(get_encryption_key('value', pk=None), value)
})
else:
element_errors = self._survey_element_validation(survey_element, data)