aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_manager
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2017-04-28 15:22:15 +0200
committerasteroide <thomas.duval@orange.com>2017-04-28 15:22:15 +0200
commit6ca63399c475f534b9fa533f38e5642fc2122c44 (patch)
tree9ccefcef4f7cfb0957fdb3a70ea5697343cc4e5a /moonv4/moon_manager
parentf8c6b6b08acbfbf3b10f0ba4421129c78aded250 (diff)
Fix a bug when saving a perimeter element
Change-Id: Ie274c020cb3f3a1776d10ca9850c5c424d693c5b
Diffstat (limited to 'moonv4/moon_manager')
-rw-r--r--moonv4/moon_manager/moon_manager/api/policies.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/moonv4/moon_manager/moon_manager/api/policies.py b/moonv4/moon_manager/moon_manager/api/policies.py
index e2f332e2..8b242478 100644
--- a/moonv4/moon_manager/moon_manager/api/policies.py
+++ b/moonv4/moon_manager/moon_manager/api/policies.py
@@ -74,6 +74,12 @@ class Perimeter(object):
def set_subject(self, ctx, args):
try:
+ if not ctx["perimeter_id"]:
+ data = self.manager.get_subjects(user_id=ctx["user_id"], policy_id=None)
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_subject(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e:
@@ -105,6 +111,11 @@ class Perimeter(object):
def set_object(self, ctx, args):
try:
+ data = self.manager.get_objects(user_id=ctx["user_id"], policy_id=None)
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_object(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e:
@@ -136,6 +147,11 @@ class Perimeter(object):
def set_action(self, ctx, args):
try:
+ data = self.manager.get_actions(user_id=ctx["user_id"], policy_id=None)
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_action(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e: