From 59dc2a2cb832f69334ceb5810b93ba96675d0b37 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Tue, 8 Apr 2014 15:41:40 -0400 Subject: [PATCH] AC-1158 Fix project to set delete on next update. --- awx/main/models/projects.py | 5 ++++- awx/main/models/unified_jobs.py | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index 81c23f3fef..6817a44f4e 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -292,9 +292,12 @@ class Project(UnifiedJobTemplate, ProjectOptions): def _can_update(self): return bool(self.scm_type) - def create_project_update(self, **kwargs): + def _update_unified_job_kwargs(self, **kwargs): if self.scm_delete_on_next_update: kwargs['scm_delete_on_update'] = True + return kwargs + + def create_project_update(self, **kwargs): return self.create_unified_job(**kwargs) @property diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py index 10416df976..7c4f808f63 100644 --- a/awx/main/models/unified_jobs.py +++ b/awx/main/models/unified_jobs.py @@ -254,6 +254,12 @@ class UnifiedJobTemplate(PolymorphicModel, CommonModelNameNotUnique): ''' raise NotImplementedError # Implement in subclass. + def _update_unified_job_kwargs(self, **kwargs): + ''' + Hook for subclasses to update kwargs. + ''' + return kwargs # Override if needed in subclass. + def create_unified_job(self, **kwargs): ''' Create a new unified job based on this unified job template. @@ -270,6 +276,7 @@ class UnifiedJobTemplate(PolymorphicModel, CommonModelNameNotUnique): if hasattr(self, '%s_id' % field_name) and ('%s_id' % field_name) in kwargs: continue kwargs[field_name] = getattr(self, field_name) + kwargs = self._update_unified_job_kwargs(**kwargs) unified_job = unified_job_class(**kwargs) if save_unified_job: unified_job.save()