Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 1 | from core.models import Site, SiteDeployments |
| 2 | from observer.deleter import Deleter |
| 3 | from observer.deleters.site_deployment_deleter import SiteDeploymentDeleter |
| 4 | |
| 5 | class SiteDeleter(Deleter): |
| 6 | model='Site' |
| 7 | |
| 8 | def call(self, pk): |
| 9 | site = Site.objects.get(pk=pk) |
| 10 | site_deployments = SiteDeployments.objects.filter(site=site) |
| 11 | site_deployment_deleter = SiteDeploymentDeleter() |
| 12 | for site_deployment in site_deployments: |
| 13 | site_deployment_deleter(site_deployment.id) |
| 14 | site.delete() |