Tony Mack | ce4e2c2 | 2015-01-06 23:48:02 -0500 | [diff] [blame] | 1 | def handle(site_privilege): |
| 2 | from core.models import Controller, SitePrivilege, ControllerSitePrivilege |
| 3 | |
| 4 | # apply site privilage at all controllers |
| 5 | controller_site_privileges = ControllerSitePrivilege.objects.filter( |
| 6 | site_privilege = site_privilege, |
| 7 | ) |
| 8 | existing_controllers = [csp.controller for sp in controller_site_privileges] |
| 9 | all_controllers = Controller.objects.all() |
| 10 | for controller in all_controllers: |
| 11 | if controller not in existing_controllers: |
| 12 | ctrl_site_priv = ControllerSitePrivilege(controller=controller, site_privilege=site_privilege) |
| 13 | ctrl_site_priv.save() |
| 14 | |