Sapan Bhatia | 39e8558 | 2014-11-19 15:07:36 -0500 | [diff] [blame] | 1 | from core.models import Site, SiteDeployments |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 2 | from observer.deleter import Deleter |
Sapan Bhatia | 39e8558 | 2014-11-19 15:07:36 -0500 | [diff] [blame] | 3 | from observer.deleters.site_deployment_deleter import SiteDeploymentsDeleter |
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) |
Sapan Bhatia | 39e8558 | 2014-11-19 15:07:36 -0500 | [diff] [blame] | 10 | site_deployments = SiteDeployments.objects.filter(site=site) |
| 11 | site_deployment_deleter = SiteDeploymentsDeleter() |
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() |