blob: 07fe6f3bfa88da4191cb0637f541f5b91d84fccd [file] [log] [blame]
Scott Bakeraf599eb2017-03-21 12:43:26 -07001from synchronizers.new_base.modelaccessor import *
Scott Bakerb63ea792016-08-11 10:24:48 -07002
3def handle(site):
Scott Bakerb63ea792016-08-11 10:24:48 -07004 # site = Site.get(site_id)
5 # make sure site has a ControllerSite record for each controller
Scott Bakeraf599eb2017-03-21 12:43:26 -07006 ctrl_sites = ControllerSite.objects.filter(site_id=site.id)
Scott Bakerb63ea792016-08-11 10:24:48 -07007 existing_controllers = [cs.controller for cs in ctrl_sites]
Scott Baker5d2e8772017-05-24 12:13:47 -07008 existing_controller_ids = [c.id for c in existing_controllers]
Scott Bakerb63ea792016-08-11 10:24:48 -07009
10 all_controllers = Controller.objects.all()
11 for ctrl in all_controllers:
Scott Baker5d2e8772017-05-24 12:13:47 -070012 if ctrl.id not in existing_controller_ids:
Scott Bakerb63ea792016-08-11 10:24:48 -070013 ctrl_site = ControllerSite(controller=ctrl, site=site)
14 ctrl_site.save()