Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1 | |
| 2 | def handle(site): |
Sapan Bhatia | 085ed48 | 2015-01-17 00:56:36 +0000 | [diff] [blame] | 3 | from core.models import Controller, ControllerSite, Site |
| 4 | |
| 5 | # site = Site.get(site_id) |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 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() |