blob: 8d1424484a779d26a2f3cdc0d4eb21b0624c5ba4 [file] [log] [blame]
def handle(user):
from core.models import Controller, ControllerSite, ControllerUser, User
from collections import defaultdict
# user = User.get(user_id)
controller_users = ControllerUser.objects.filter(user=user)
existing_controllers = [cu.controller for cu in controller_users]
all_controllers = Controller.objects.all()
for controller in all_controllers:
if controller not in existing_controllers:
ctrl_user = ControllerUser(controller=controller, user=user)
ctrl_user.save()