Fix custom inventory scripts on org deletion

We'll now clear the organization for it, this requires a database
migration to accept null values for custom inventory scripts
This commit is contained in:
Matthew Jones
2015-10-19 12:05:02 -04:00
parent 4692c13a9d
commit b25413002c
3 changed files with 528 additions and 1 deletions

View File

@@ -1281,7 +1281,9 @@ class CustomInventoryScript(CommonModelNameNotUnique):
'Organization',
related_name='custom_inventory_scripts',
help_text=_('Organization owning this inventory script'),
on_delete=models.CASCADE,
blank=False,
null=True,
on_delete=models.SET_NULL,
)
def get_absolute_url(self):

View File

@@ -53,6 +53,12 @@ class Organization(CommonModel):
def __unicode__(self):
return self.name
def mark_inactive(self, save=True):
for script in self.custom_inventory_scripts.all():
script.organization = None
script.save()
super(Organization, self).mark_inactive(save=save)
class Team(CommonModelNameNotUnique):
'''