Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 1 | from core.models import User, UserDeployments |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 2 | from observer.deleter import Deleter |
| 3 | |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4 | class UserDeploymentsDeleter(Deleter): |
| 5 | model='UserDeployments' |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 6 | |
| 7 | def call(self, pk): |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 8 | user_deployment = UserDeployments.objects.get(pk=pk) |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 9 | if user_deployment.user.kuser_id: |
| 10 | driver = self.driver.admin_driver(deployment=user_deployment.deployment.name) |
| 11 | driver.delete_user(user_deployment.user.kuser_id) |
| 12 | user_deployment.delete() |