Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 1 | |
| 2 | def handle(site): |
| 3 | from core.models import Controller, ControllerSite, Site |
| 4 | |
| 5 | # site = Site.get(site_id) |
| 6 | # make sure site has a ControllerSite record for each controller |
| 7 | ctrl_sites = ControllerSite.objects.filter(site=site) |
| 8 | existing_controllers = [cs.controller for cs in ctrl_sites] |
| 9 | |
| 10 | all_controllers = Controller.objects.all() |
| 11 | for ctrl in all_controllers: |
| 12 | if ctrl not in existing_controllers: |
| 13 | ctrl_site = ControllerSite(controller=ctrl, site=site) |
| 14 | ctrl_site.save() |