mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 06:56:00 -03:30
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:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user