blob: b82ea4ae586937a45f6cc6de5c39bce4327f411b [file] [log] [blame]
Tony Mackbdb188a2014-04-01 20:24:47 -04001from core.models import User, UserDeployments
Tony Mack387a73f2013-09-18 07:59:14 -04002from observer.deleter import Deleter
3
4class UserDeleter(Deleter):
5 model='User'
6
7 def call(self, pk):
8 user = User.objects.get(pk=pk)
Tony Mackbdb188a2014-04-01 20:24:47 -04009 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 Mack387a73f2013-09-18 07:59:14 -040015 user.delete()