Tony Mack | ffe6d8b | 2015-01-06 23:48:02 -0500 | [diff] [blame] | 1 | def handle(slice_privilege): |
| 2 | from core.models import Controller, SlicePrivilege, ControllerSlicePrivilege |
Sapan Bhatia | 085ed48 | 2015-01-17 00:56:36 +0000 | [diff] [blame] | 3 | |
| 4 | # slice_privilege = SlicePrivilege.get(slice_privilege_id) |
Tony Mack | ffe6d8b | 2015-01-06 23:48:02 -0500 | [diff] [blame] | 5 | # apply slice privilage at all controllers |
| 6 | controller_slice_privileges = ControllerSlicePrivilege.objects.filter( |
| 7 | slice_privilege = slice_privilege, |
| 8 | ) |
| 9 | existing_controllers = [csp.controller for sp in controller_slice_privileges] |
| 10 | all_controllers = Controller.objects.all() |
| 11 | for controller in all_controllers: |
| 12 | if controller not in existing_controllers: |
| 13 | ctrl_slice_priv = ControllerSlicePrivilege(controller=controller, slice_privilege=slice_privilege) |
| 14 | ctrl_slice_priv.save() |
| 15 | |