From 867a2eefc80e7a4da83759469c1cb49cc30a0745 Mon Sep 17 00:00:00 2001 From: Eduardo Sousa Date: Wed, 29 May 2019 09:53:36 +0100 Subject: [PATCH] Enhancing role filters Change-Id: I7ff9d069ccbb1911fd0e634b846b0ad2993d1abe Signed-off-by: Eduardo Sousa --- osm_nbi/admin_topics.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 77b9688..d6112e1 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -751,7 +751,7 @@ class RoleTopicAuth(BaseTopic): :param role_definitions: role definition to test :return: None if ok, raises ValidationError exception on error """ - ignore_fields = ["_id", "name"] + ignore_fields = ["_id", "_admin", "name"] for role_def in role_definitions.keys(): if role_def in ignore_fields: continue @@ -919,7 +919,7 @@ class RoleTopicAuth(BaseTopic): :param _id: server internal id :return: dictionary, raise exception if not found. """ - filter_db = self._get_project_filter(session, write=False, show_all=True) + filter_db = self._get_project_filter(session) filter_db["_id"] = _id role = self.db.get_one(self.topic, filter_db) @@ -939,6 +939,17 @@ class RoleTopicAuth(BaseTopic): if not filter_q: filter_q = {} + if "root" in filter_q: + filter_q[":"] = filter_q["root"] + del filter_q["root"] + + if len(filter_q) > 0: + keys = [key for key in filter_q.keys() if "." in key] + + for key in keys: + filter_q[key.replace(".", ":")] = filter_q[key] + del filter_q[key] + roles = self.db.get_list(self.topic, filter_q) new_roles = [] -- 2.25.1