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 SitePrivilegePolicy(Policy): |
| 5 | model_name = "SitePrivilege" |
| 6 | |
| 7 | def handle_create(self, site_privilege): |
| 8 | return self.handle_update(site_privilege) |
| 9 | |
| 10 | def handle_update(self, site_privilege): |
| 11 | # site_privilege = SitePrivilege.get(site_privilege_id) |
| 12 | # apply site privilage at all controllers |
| 13 | controller_site_privileges = ControllerSitePrivilege.objects.filter( |
| 14 | site_privilege_id = site_privilege.id, |
| 15 | ) |
| 16 | existing_controllers = [sp.controller for sp in controller_site_privileges] |
| 17 | all_controllers = Controller.objects.all() |
| 18 | for controller in all_controllers: |
| 19 | if controller not in existing_controllers: |
| 20 | ctrl_site_priv = ControllerSitePrivilege(controller=controller, site_privilege=site_privilege) |
| 21 | ctrl_site_priv.save() |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 22 | |