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