From ec643d64063860a7e04c1f1a6e9504e410d3c80f Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Tue, 10 Jul 2018 08:45:23 -0400 Subject: [PATCH] fix regression of callback relaunch --- awx/main/access.py | 2 +- awx/main/models/jobs.py | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/awx/main/access.py b/awx/main/access.py index 60ff0846bd..ca049ff6a3 100644 --- a/awx/main/access.py +++ b/awx/main/access.py @@ -1504,7 +1504,7 @@ class JobAccess(BaseAccess): if obj.job_template is not None: if config is None: prompts_access = False - elif config.prompts_dict() == {}: + elif not config.has_user_prompts(obj.job_template): prompts_access = True elif obj.created_by_id != self.user.pk: prompts_access = False diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 532dca10b4..e6a6733895 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -963,11 +963,22 @@ class JobLaunchConfig(LaunchTimeConfig): editable=False, ) + def has_user_prompts(self, template): + ''' + Returns True if any fields exist in the launch config that are + not permissions exclusions + (has to exist because of callback relaunch exception) + ''' + return self._has_user_prompts(template, only_unprompted=False) + def has_unprompted(self, template): ''' - returns False if the template has set ask_ fields to False after + returns True if the template has set ask_ fields to False after launching with those prompts ''' + return self._has_user_prompts(template, only_unprompted=True) + + def _has_user_prompts(self, template, only_unprompted=True): prompts = self.prompts_dict() ask_mapping = template.get_ask_mapping() if template.survey_enabled and (not template.ask_variables_on_launch): @@ -977,10 +988,10 @@ class JobLaunchConfig(LaunchTimeConfig): element.get('variable') for element in template.survey_spec.get('spec', {}) if 'variable' in element ) - if provided_vars - survey_vars: + if (provided_vars and not only_unprompted) or (provided_vars - survey_vars): return True for field_name, ask_field_name in ask_mapping.items(): - if field_name in prompts and not getattr(template, ask_field_name): + if field_name in prompts and not (getattr(template, ask_field_name) and only_unprompted): if field_name == 'limit' and self.job and self.job.launch_type == 'callback': continue # exception for relaunching callbacks return True