From 7b4e2953a6e78e3c5b526ba5368e8f3b1d63b790 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Wed, 28 Jan 2015 10:11:10 -0500 Subject: [PATCH] did not previously translate project update parent instance correctly --- awx/main/models/projects.py | 10 ++++++---- awx/main/models/unified_jobs.py | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index 8487b81010..cdcdf5395b 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -364,7 +364,9 @@ class ProjectUpdate(UnifiedJob, ProjectOptions): parent_instance = self._get_parent_instance() if parent_instance: update_fields = self._update_parent_instance_no_save(parent_instance) - if not self.failed and parent_instance.scm_delete_on_next_update: - parent_instance.scm_delete_on_next_update = False - update_fields.append('scm_delete_on_next_update') - parent_instance.save(update_fields=update_fields) + if self.status in ('successful', 'failed', 'error', 'canceled'): + if not self.failed and parent_instance.scm_delete_on_next_update: + parent_instance.scm_delete_on_next_update = False + if 'scm_delete_on_next_update' not in update_fields: + update_fields.append('scm_delete_on_next_update') + parent_instance.save(update_fields=update_fields) diff --git a/awx/main/models/unified_jobs.py b/awx/main/models/unified_jobs.py index f4ce0516e4..dfc51cbec4 100644 --- a/awx/main/models/unified_jobs.py +++ b/awx/main/models/unified_jobs.py @@ -480,7 +480,8 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique def _update_parent_instance_no_save(self, parent_instance, update_fields=[]): def parent_instance_set(key, val): setattr(parent_instance, key, val) - update_fields.append(key) + if key not in update_fields: + update_fields.append(key) if parent_instance: if self.status in ('pending', 'waiting', 'running'):