Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 1 | def handle(user): |
| 2 | from core.models import Controller, ControllerSite, ControllerUser, User |
| 3 | from collections import defaultdict |
| 4 | |
| 5 | # user = User.get(user_id) |
| 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() |
| 14 | |