Sapan Bhatia | 3d872e5 | 2014-11-11 21:41:12 -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 |
| 3 | |
| 4 | class SiteDeploymentDeleter(Deleter): |
Sapan Bhatia | 3d872e5 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 5 | model='SiteDeployment' |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 6 | |
| 7 | def call(self, pk): |
Sapan Bhatia | 3d872e5 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 8 | site_deployment = SiteDeployment.objects.get(pk=pk) |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 9 | if site_deployment.tenant_id: |
| 10 | driver = self.driver.admin_driver(deployment=site_deployment.deployment.name) |
| 11 | driver.delete_tenant(site_deployment.tenant_id) |
| 12 | site_deployment.delete() |