checking in missing site/slice privilege steps
diff --git a/planetstack/model_policies/__init__.py b/planetstack/model_policies/__init__.py
index ac395a1..f1c8071 100644
--- a/planetstack/model_policies/__init__.py
+++ b/planetstack/model_policies/__init__.py
@@ -2,3 +2,5 @@
from .model_policy_User import *
from .model_policy_Network import *
from .model_policy_Site import *
+from .model_policy_SitePrivilege import *
+from .model_policy_SlicePrivilege import *
diff --git a/planetstack/model_policies/model_policy_SitePrivilege.py b/planetstack/model_policies/model_policy_SitePrivilege.py
new file mode 100644
index 0000000..90280a3
--- /dev/null
+++ b/planetstack/model_policies/model_policy_SitePrivilege.py
@@ -0,0 +1,14 @@
+def handle(site_privilege):
+ from core.models import Controller, SitePrivilege, ControllerSitePrivilege
+
+ # apply site privilage at all controllers
+ controller_site_privileges = ControllerSitePrivilege.objects.filter(
+ site_privilege = site_privilege,
+ )
+ existing_controllers = [csp.controller for sp in controller_site_privileges]
+ all_controllers = Controller.objects.all()
+ for controller in all_controllers:
+ if controller not in existing_controllers:
+ ctrl_site_priv = ControllerSitePrivilege(controller=controller, site_privilege=site_privilege)
+ ctrl_site_priv.save()
+
diff --git a/planetstack/model_policies/model_policy_SlicePrivilege.py b/planetstack/model_policies/model_policy_SlicePrivilege.py
new file mode 100644
index 0000000..0f772cb
--- /dev/null
+++ b/planetstack/model_policies/model_policy_SlicePrivilege.py
@@ -0,0 +1,14 @@
+def handle(slice_privilege):
+ from core.models import Controller, SlicePrivilege, ControllerSlicePrivilege
+
+ # apply slice privilage at all controllers
+ controller_slice_privileges = ControllerSlicePrivilege.objects.filter(
+ slice_privilege = slice_privilege,
+ )
+ existing_controllers = [csp.controller for sp in controller_slice_privileges]
+ all_controllers = Controller.objects.all()
+ for controller in all_controllers:
+ if controller not in existing_controllers:
+ ctrl_slice_priv = ControllerSlicePrivilege(controller=controller, slice_privilege=slice_privilege)
+ ctrl_slice_priv.save()
+