Tony Mack | bdb188a | 2014-04-01 20:24:47 -0400 | [diff] [blame] | 1 | from core.models import User, UserDeployments |
Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 2 | from observer.deleter import Deleter |
| 3 | |
| 4 | class UserDeleter(Deleter): |
| 5 | model='User' |
| 6 | |
| 7 | def call(self, pk): |
| 8 | user = User.objects.get(pk=pk) |
Tony Mack | bdb188a | 2014-04-01 20:24:47 -0400 | [diff] [blame] | 9 | user_deployments = UserDeployments.objects.filter(user=user) |
| 10 | for user_deployment in user_deployments: |
| 11 | if user_deployment.user.kuser_id: |
| 12 | driver = self.driver.admin_driver(deployment=user_deployment.deployment.name) |
| 13 | driver.delete_user(user_deployment.user.kuser_id) |
| 14 | user_deployment.delete() |
Tony Mack | 387a73f | 2013-09-18 07:59:14 -0400 | [diff] [blame] | 15 | user.delete() |