From 871f8888918592d5c2357a8034e1b0f098a26fee Mon Sep 17 00:00:00 2001 From: Eduardo Sousa Date: Wed, 29 May 2019 14:43:05 +0100 Subject: [PATCH 1/1] Maintaining representation for root through API Change-Id: Ia5c5f27bb63ae81e2d410dbb02a1bf04c1132cab Signed-off-by: Eduardo Sousa --- osm_nbi/admin_topics.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 924ebdd..eb8c988 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -862,7 +862,13 @@ class RoleTopicAuth(BaseTopic): if not content["_admin"].get("created"): content["_admin"]["created"] = now content["_admin"]["modified"] = now - content[":"] = False + + if "." in content.keys(): + content["root"] = content["."] + del content["."] + + if "root" not in content.keys(): + content["root"] = False ignore_fields = ["_id", "_admin", "name"] content_keys = content.keys() @@ -893,8 +899,12 @@ class RoleTopicAuth(BaseTopic): for role_def, value in edit_content.items(): final_content[role_def.replace(".", ":")] = value - if ":" not in final_content.keys(): - final_content[":"] = False + if ":" in final_content.keys(): + final_content["root"] = final_content[":"] + del final_content[":"] + + if "root" not in final_content.keys(): + final_content["root"] = False @staticmethod def format_on_show(content): -- 2.17.1