Sapan Bhatia | 3b18203 | 2014-09-03 15:38:56 -0400 | [diff] [blame] | 1 | def handle(user): |
Sapan Bhatia | 085ed48 | 2015-01-17 00:56:36 +0000 | [diff] [blame] | 2 | from core.models import Controller, ControllerSite, ControllerUser, User |
Tony Mack | 2656436 | 2015-01-06 17:49:25 -0500 | [diff] [blame] | 3 | from collections import defaultdict |
Sapan Bhatia | 085ed48 | 2015-01-17 00:56:36 +0000 | [diff] [blame] | 4 | |
| 5 | # user = User.get(user_id) |
Tony Mack | 2656436 | 2015-01-06 17:49:25 -0500 | [diff] [blame] | 6 | |
| 7 | controller_users = ControllerUser.objects.filter(user=user) |
| 8 | existing_controllers = [cu.controller for cu in controller_users] |
| 9 | all_controllers = Controller.objects.all() |
| 10 | for controller in all_controllers: |
| 11 | if controller not in existing_controllers: |
| 12 | ctrl_user = ControllerUser(controller=controller, user=user) |
| 13 | ctrl_user.save() |
Sapan Bhatia | 3b18203 | 2014-09-03 15:38:56 -0400 | [diff] [blame] | 14 | |