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 | |
Sapan Bhatia | 485490d | 2015-01-17 00:56:36 +0000 | [diff] [blame] | 4 | # site_privilege = SitePrivilege.get(site_privilege_id) |
Tony Mack | ce4e2c2 | 2015-01-06 23:48:02 -0500 | [diff] [blame] | 5 | # apply site privilage at all controllers |
| 6 | controller_site_privileges = ControllerSitePrivilege.objects.filter( |
| 7 | site_privilege = site_privilege, |
| 8 | ) |
Sapan Bhatia | b6d5b87 | 2015-01-23 16:11:29 +0000 | [diff] [blame] | 9 | existing_controllers = [sp.controller for sp in controller_site_privileges] |
Tony Mack | ce4e2c2 | 2015-01-06 23:48:02 -0500 | [diff] [blame] | 10 | all_controllers = Controller.objects.all() |
| 11 | for controller in all_controllers: |
| 12 | if controller not in existing_controllers: |
| 13 | ctrl_site_priv = ControllerSitePrivilege(controller=controller, site_privilege=site_privilege) |
| 14 | ctrl_site_priv.save() |
| 15 | |