Sapan Bhatia | 3b18203 | 2014-09-03 15:38:56 -0400 | [diff] [blame] | 1 | def handle(user): |
Sapan Bhatia | 485490d | 2015-01-17 00:56:36 +0000 | [diff] [blame] | 2 | from core.models import Controller, ControllerSite, ControllerUser, User |
Tony Mack | 7436493 | 2015-01-06 17:49:25 -0500 | [diff] [blame] | 3 | from collections import defaultdict |
Sapan Bhatia | 485490d | 2015-01-17 00:56:36 +0000 | [diff] [blame] | 4 | |
| 5 | # user = User.get(user_id) |
Tony Mack | 7436493 | 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 | |