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 | 79e78c8 | 2014-04-12 10:26:15 -0400 | [diff] [blame] | 3 | from observer.deleters.site_deployment_deleter import SiteDeploymentDeleter |
Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 4 | |
| 5 | class SiteDeleter(Deleter): |
| 6 | model='Site' |
| 7 | |
| 8 | def call(self, pk): |
| 9 | site = Site.objects.get(pk=pk) |
Tony Mack | bdb188a | 2014-04-01 20:24:47 -0400 | [diff] [blame] | 10 | site_deployments = SiteDeployments.objects.filter(site=site) |
Tony Mack | 79e78c8 | 2014-04-12 10:26:15 -0400 | [diff] [blame] | 11 | site_deployment_deleter = SiteDeploymentDeleter() |
Tony Mack | bdb188a | 2014-04-01 20:24:47 -0400 | [diff] [blame] | 12 | for site_deployment in site_deployments: |
Tony Mack | 79e78c8 | 2014-04-12 10:26:15 -0400 | [diff] [blame] | 13 | site_deployment_deleter(site_deployment.id) |
Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 14 | site.delete() |