diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 5f136ee5b2..e6c2020d1f 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1364,9 +1364,9 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions): @classmethod def _get_unified_job_field_names(cls): - return ['name', 'description', 'source', 'source_path', 'source_script', 'source_vars', 'schedule', - 'credential', 'source_regions', 'instance_filters', 'group_by', 'overwrite', 'overwrite_vars', - 'timeout', 'verbosity', 'source_project_update',] + return set(f.name for f in InventorySourceOptions._meta.fields) | set( + ['name', 'description', 'schedule'] + ) def save(self, *args, **kwargs): # If update_fields has been specified, add our field names to it, diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index beaceab0a8..6aea344e64 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -289,13 +289,9 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour @classmethod def _get_unified_job_field_names(cls): - return ['name', 'description', 'job_type', 'inventory', 'project', - 'playbook', 'credentials', 'forks', 'schedule', 'limit', - 'verbosity', 'job_tags', 'extra_vars', - 'force_handlers', 'skip_tags', 'start_at_task', - 'become_enabled', 'labels', 'survey_passwords', - 'allow_simultaneous', 'timeout', 'use_fact_cache', - 'diff_mode',] + return set(f.name for f in JobOptions._meta.fields) | set( + ['name', 'description', 'schedule', 'survey_passwords', 'labels', 'credentials'] + ) @property def validation_errors(self): diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index a8578b97bd..eafd92e5a5 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -306,9 +306,9 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin): @classmethod def _get_unified_job_field_names(cls): - return ['name', 'description', 'local_path', 'scm_type', 'scm_url', - 'scm_branch', 'scm_clean', 'scm_delete_on_update', - 'credential', 'schedule', 'timeout',] + return set(f.name for f in ProjectOptions._meta.fields) | set( + ['name', 'description', 'schedule'] + ) def save(self, *args, **kwargs): new_instance = not bool(self.pk) diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py index 1d2a4eb221..726376f6b9 100644 --- a/awx/main/models/unified_jobs.py +++ b/awx/main/models/unified_jobs.py @@ -838,7 +838,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique unified_job_class = self.__class__ unified_jt_class = self._get_unified_job_template_class() parent_field_name = unified_job_class._get_parent_field_name() - fields = unified_jt_class._get_unified_job_field_names() + [parent_field_name] + fields = unified_jt_class._get_unified_job_field_names() | set([parent_field_name]) create_data = {"launch_type": "relaunch"} if limit: diff --git a/awx/main/models/workflow.py b/awx/main/models/workflow.py index 78978f998c..d47745e1b8 100644 --- a/awx/main/models/workflow.py +++ b/awx/main/models/workflow.py @@ -316,15 +316,16 @@ class WorkflowJobTemplate(UnifiedJobTemplate, WorkflowJobOptions, SurveyJobTempl @classmethod def _get_unified_job_field_names(cls): - return ['name', 'description', 'extra_vars', 'labels', 'survey_passwords', - 'schedule', 'launch_type', 'allow_simultaneous'] + return set(f.name for f in WorkflowJobOptions._meta.fields) | set( + ['name', 'description', 'schedule', 'survey_passwords', 'labels'] + ) @classmethod def _get_unified_jt_copy_names(cls): base_list = super(WorkflowJobTemplate, cls)._get_unified_jt_copy_names() base_list.remove('labels') - return (base_list + - ['survey_spec', 'survey_enabled', 'ask_variables_on_launch', 'organization']) + return (base_list | + set(['survey_spec', 'survey_enabled', 'ask_variables_on_launch', 'organization'])) def get_absolute_url(self, request=None): return reverse('api:workflow_job_template_detail', kwargs={'pk': self.pk}, request=request)