Fix for AC-284. Delete groups when they are disassociated and have no more parents. Remove all group and host associations from a group when it is marked inactive.

This commit is contained in:
Chris Church
2013-07-27 23:00:07 -04:00
parent 222bbd7c98
commit fce1a04a76
5 changed files with 70 additions and 12 deletions

View File

@@ -269,6 +269,16 @@ class Group(CommonModelNameNotUnique):
def get_absolute_url(self):
return reverse('main:group_detail', args=(self.pk,))
def mark_inactive(self, save=True):
'''
When marking groups inactive, remove all associations to related
groups/hosts.
'''
super(Group, self).mark_inactive(save=save)
self.parents.clear()
self.children.clear()
self.hosts.clear()
def update_has_active_failures(self):
failed_hosts = self.all_hosts.filter(active=True,
last_job_host_summary__job__active=True,