Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1 | from core.models import Site, SiteDeployment |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 2 | from observer.deleter import Deleter |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3 | from observer.deleters.site_deployment_deleter import SiteDeploymentDeleter |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -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 | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 10 | site_deployments = SiteDeployment.objects.filter(site=site) |
| 11 | site_deployment_deleter = SiteDeploymentDeleter() |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 12 | for site_deployment in site_deployments: |
| 13 | site_deployment_deleter(site_deployment.id) |
| 14 | site.delete() |