blob: 10600fb0e154b00c572e3b49952c2fd050007233 [file] [log] [blame]
Scott Bakeraf599eb2017-03-21 12:43:26 -07001from synchronizers.new_base.modelaccessor import *
Scott Baker46a3ee92017-05-30 16:44:56 -07002from synchronizers.new_base.policy import Policy
Scott Bakeraf599eb2017-03-21 12:43:26 -07003
Scott Baker46a3ee92017-05-30 16:44:56 -07004class 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 Bakerb63ea792016-08-11 10:24:48 -070022