Scott Baker | af599eb | 2017-03-21 12:43:26 -0700 | [diff] [blame] | 1 | from synchronizers.new_base.modelaccessor import * |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 2 | |
| 3 | def handle(site): |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 4 | # site = Site.get(site_id) |
| 5 | # make sure site has a ControllerSite record for each controller |
Scott Baker | af599eb | 2017-03-21 12:43:26 -0700 | [diff] [blame] | 6 | ctrl_sites = ControllerSite.objects.filter(site_id=site.id) |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 7 | existing_controllers = [cs.controller for cs in ctrl_sites] |
Scott Baker | 5d2e877 | 2017-05-24 12:13:47 -0700 | [diff] [blame] | 8 | existing_controller_ids = [c.id for c in existing_controllers] |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 9 | |
| 10 | all_controllers = Controller.objects.all() |
| 11 | for ctrl in all_controllers: |
Scott Baker | 5d2e877 | 2017-05-24 12:13:47 -0700 | [diff] [blame] | 12 | if ctrl.id not in existing_controller_ids: |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 13 | ctrl_site = ControllerSite(controller=ctrl, site=site) |
| 14 | ctrl_site.save() |