From 9cc31e122dc2119a94c767e72f24e6ab27d31f73 Mon Sep 17 00:00:00 2001 From: Eduardo Sousa Date: Thu, 30 May 2019 13:23:04 +0100 Subject: [PATCH] Maintaining format for project_role_mapping for creating and listing Change-Id: I725451a39e32431a23745b4a20f7823fce090793 Signed-off-by: Eduardo Sousa --- osmclient/sol005/user.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osmclient/sol005/user.py b/osmclient/sol005/user.py index 1321aa5..7736ea0 100644 --- a/osmclient/sol005/user.py +++ b/osmclient/sol005/user.py @@ -49,7 +49,7 @@ class User(object): project, roles = set_mapping_clean[0], set_mapping_clean[1:] for role in roles: - mapping = [project, role] + mapping = {"project": project, "role": role} if mapping not in project_role_mappings: project_role_mappings.append(mapping) @@ -97,16 +97,17 @@ class User(object): update_user["project_role_mappings"] = [mapping for mapping in update_user["project_role_mappings"] - if mapping[0] != project] + if mapping["project"] != project] for role in roles: - update_user["project_role_mappings"].append([project, role]) + mapping = {"project": project, "role": role} + update_user["project_role_mappings"].append(mapping) if user["remove-project"]: for remove_project in user["remove-project"]: update_user["project_role_mappings"] = [mapping for mapping in update_user["project_role_mappings"] - if mapping[0] != remove_project] + if mapping["project"] != remove_project] if user["add-project-role"]: for add_project_role in user["add-project-role"]: @@ -114,7 +115,7 @@ class User(object): project, roles = add_project_role_clean[0], add_project_role_clean[1:] for role in roles: - mapping = [project, role] + mapping = {"project": project, "role": role} if mapping not in update_user["project_role_mappings"]: update_user["project_role_mappings"].append(mapping) @@ -124,7 +125,7 @@ class User(object): project, roles = remove_project_role_clean[0], remove_project_role_clean[1:] for role in roles: - mapping_to_remove = [project, role] + mapping_to_remove = {"project": project, "role": role} update_user["project_role_mappings"] = [mapping for mapping in update_user["project_role_mappings"] if mapping != mapping_to_remove] -- 2.25.1