From: Eduardo Sousa Date: Wed, 29 May 2019 13:43:05 +0000 (+0100) Subject: Maintaining representation for root through API X-Git-Tag: v6.0.0~29 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F7574%2F2;p=osm%2FNBI.git Maintaining representation for root through API Change-Id: Ia5c5f27bb63ae81e2d410dbb02a1bf04c1132cab Signed-off-by: Eduardo Sousa --- 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):