Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1 | |
| 2 | def handle(site): |
Tony Mack | 2656436 | 2015-01-06 17:49:25 -0500 | [diff] [blame] | 3 | from core.models import Controller, ControllerSite |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 4 | # make sure site has a ControllerSite record for each controller |
| 5 | ctrl_sites = ControllerSite.objects.filter(site=site) |
| 6 | existing_controllers = [cs.controller for cs in ctrl_sites] |
| 7 | |
| 8 | all_controllers = Controller.objects.all() |
| 9 | for ctrl in all_controllers: |
| 10 | if ctrl not in existing_controllers: |
| 11 | ctrl_site = ControllerSite(controller=ctrl, site=site) |
| 12 | ctrl_site.save() |