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 |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 3 | from observer.deleters.user_deployment_deleter import UserDeploymentsDeleter |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 4 | |
| 5 | class UserDeleter(Deleter): |
| 6 | model='User' |
| 7 | |
| 8 | def call(self, pk): |
| 9 | user = User.objects.get(pk=pk) |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 10 | user_deployment_deleter = UserDeploymentsDeleter() |
| 11 | for user_deployment in UserDeployments.objects.filter(user=user): |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 12 | user_deployment_deleter(user_deployment.id) |
| 13 | user.delete() |