From 00156a55189c077ead2d155a7839d4a2048e376f Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 4 Feb 2014 09:55:55 -0500 Subject: [PATCH] Updating AC-984... only conditionally recompute inventory fields in group delete if it isn't a part of an inventory delete --- awx/main/models/inventory.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 3c626e9bf2..4a9a2c2355 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -105,7 +105,7 @@ class Inventory(CommonModel): for host in self.hosts.filter(active=True): host.mark_inactive() for group in self.groups.filter(active=True): - group.mark_inactive() + group.mark_inactive(recompute=False) for inventory_source in self.inventory_sources.filter(active=True): inventory_source.mark_inactive() super(Inventory, self).mark_inactive(save=save) @@ -352,22 +352,27 @@ class Group(CommonModelNameNotUnique): def get_absolute_url(self): return reverse('api:group_detail', args=(self.pk,)) - def mark_inactive(self, save=True): + def mark_inactive(self, save=True, recompute=True): ''' When marking groups inactive, remove all associations to related groups/hosts/inventory_sources. ''' - from awx.main.signals import ignore_inventory_computed_fields - i = self.inventory - - with ignore_inventory_computed_fields(): + def mark_actual(): super(Group, self).mark_inactive(save=save) self.inventory_source.mark_inactive(save=save) self.inventory_sources.clear() self.parents.clear() self.children.clear() self.hosts.clear() - i.update_computed_fields() + from awx.main.signals import ignore_inventory_computed_fields + i = self.inventory + + if recompute: + with ignore_inventory_computed_fields(): + mark_actual() + i.update_computed_fields() + else: + mark_actual() def update_computed_fields(self): '''