blob: 448b58f259ee05aabb1ec19f4369d88d24ca7a2f [file] [log] [blame]
Scott Bakeraf599eb2017-03-21 12:43:26 -07001from synchronizers.new_base.modelaccessor import *
Scott Bakerb63ea792016-08-11 10:24:48 -07002
Scott Bakeraf599eb2017-03-21 12:43:26 -07003def handle(user):
Scott Bakera0a688a2017-03-28 11:59:56 -07004 controller_users = ControllerUser.objects.filter(user_id=user.id)
Scott Bakerb63ea792016-08-11 10:24:48 -07005 existing_controllers = [cu.controller for cu in controller_users]
Scott Bakera0a688a2017-03-28 11:59:56 -07006 existing_controller_ids = [c.id for c in existing_controllers]
Scott Bakerb63ea792016-08-11 10:24:48 -07007 all_controllers = Controller.objects.all()
8 for controller in all_controllers:
Scott Bakera0a688a2017-03-28 11:59:56 -07009 if controller.id not in existing_controller_ids:
Scott Bakerb63ea792016-08-11 10:24:48 -070010 ctrl_user = ControllerUser(controller=controller, user=user)
11 ctrl_user.save()
12