1 from core.models import *
4 from core.models import Controller, ControllerSite, ControllerUser
5 from collections import defaultdict
6 ctrl_site_deployments = ControllerSite.objects.all()
7 controller_lookup = defaultdict(list)
8 for ctrl_site_deployment in ctrl_site_deployments:
9 controller_site_lookup[ctrl_site_deployment.site_deployment].append(ctrl_site_deployment)
11 controller_user_lookup = defaultdict(list)
12 for controller_user in ControllerUser.objects.all():
13 controller_user_lookup[controller_user.user].append(controller_user.controller)
16 # admins should have an account at all controllers
17 expected_controllers = controllers
19 # normal users should have an account at their site's controllers
20 #expected_controllers = controller_site_lookup[user.site]
21 # users are added to all controllers for now
22 expected_controllers = controllers
24 for expected_controller in expected_controllers:
25 if not user in controller_user_lookup or \
26 expected_controller not in controller_user_lookup[user]:
28 ud = ControllerUser(user=user, controller=expected_controller)