From: Eduardo Sousa Date: Thu, 30 May 2019 12:23:04 +0000 (+0100) Subject: Maintaining format for project_role_mapping for creating and listing X-Git-Tag: v6.0.0~9 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F7581%2F1;p=osm%2Fosmclient.git Maintaining format for project_role_mapping for creating and listing Change-Id: I725451a39e32431a23745b4a20f7823fce090793 Signed-off-by: Eduardo Sousa --- 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]