Scott Baker | af599eb | 2017-03-21 12:43:26 -0700 | [diff] [blame] | 1 | from synchronizers.new_base.modelaccessor import * |
Scott Baker | 46a3ee9 | 2017-05-30 16:44:56 -0700 | [diff] [blame^] | 2 | from synchronizers.new_base.policy import Policy |
Scott Baker | af599eb | 2017-03-21 12:43:26 -0700 | [diff] [blame] | 3 | |
Scott Baker | 46a3ee9 | 2017-05-30 16:44:56 -0700 | [diff] [blame^] | 4 | class SlicePrivilegePolicy(Policy): |
| 5 | model_name = "SlicePrivilege" |
| 6 | |
| 7 | def handle_create(self, slice_privilege): |
| 8 | return self.handle_update(slice_privilege) |
| 9 | |
| 10 | def handle_update(self, slice_privilege): |
| 11 | # slice_privilege = SlicePrivilege.get(slice_privilege_id) |
| 12 | # apply slice privilage at all controllers |
| 13 | controller_slice_privileges = ControllerSlicePrivilege.objects.filter( |
| 14 | slice_privilege = slice_privilege, |
| 15 | ) |
| 16 | existing_controllers = [sp.controller for sp in controller_slice_privileges] |
| 17 | all_controllers = Controller.objects.all() |
| 18 | for controller in all_controllers: |
| 19 | if controller not in existing_controllers: |
| 20 | ctrl_slice_priv = ControllerSlicePrivilege(controller=controller, slice_privilege=slice_privilege) |
| 21 | ctrl_slice_priv.save() |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 22 | |