Tony Mack | bdb188a | 2014-04-01 20:24:47 -0400 | [diff] [blame] | 1 | from core.models import Site, SiteDeployments |
Tony Mack | e4be32f | 2014-03-11 20:45:25 -0400 | [diff] [blame] | 2 | from observer.deleter import Deleter |
Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 3 | |
| 4 | class SiteDeleter(Deleter): |
| 5 | model='Site' |
| 6 | |
| 7 | def call(self, pk): |
| 8 | site = Site.objects.get(pk=pk) |
Tony Mack | bdb188a | 2014-04-01 20:24:47 -0400 | [diff] [blame] | 9 | site_deployments = SiteDeployments.objects.filter(site=site) |
| 10 | for site_deployment in site_deployments: |
| 11 | if site_deployment.tenant_id: |
Tony Mack | f77f140 | 2014-04-02 07:06:53 -0400 | [diff] [blame] | 12 | driver = self.driver.admin_driver(deployment=site_deployment.deployment.name) |
Tony Mack | bdb188a | 2014-04-01 20:24:47 -0400 | [diff] [blame] | 13 | driver.delete_tenant(site_deployment.tenant_id) |
| 14 | site_deployment.delete() |
Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 15 | site.delete() |