X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fadmin_topics.py;h=eb8c988498909313afe81a43c84201606b306c0b;hp=d6112e17b6ec706aa06ee4edc8763c222535c3d7;hb=871f8888918592d5c2357a8034e1b0f098a26fee;hpb=867a2eefc80e7a4da83759469c1cb49cc30a0745 diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index d6112e1..eb8c988 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -862,13 +862,20 @@ 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"] - for role_def, value in content.items(): + content_keys = content.keys() + for role_def in content_keys: if role_def in ignore_fields: continue - content[role_def.replace(".", ":")] = value + content[role_def.replace(".", ":")] = content[role_def] del content[role_def] @staticmethod @@ -892,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): @@ -906,6 +917,8 @@ class RoleTopicAuth(BaseTopic): """ content_keys = list(content.keys()) + content["_id"] = str(content["_id"]) + for key in content_keys: if ":" in key: content[key.replace(":", ".")] = content[key]