From fdc97c8f4c123dcb23865e08d187df025123a7f8 Mon Sep 17 00:00:00 2001 From: tierno Date: Wed, 13 Mar 2019 09:55:51 +0000 Subject: [PATCH] fix bug 647 user creation with project prompt Change-Id: I6d006d25b33ec8693ffaf71252c6cc009a63b5ef Signed-off-by: tierno --- osmclient/scripts/osm.py | 3 ++- osmclient/sol005/user.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 821c1a9..7aa9e39 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -2236,8 +2236,9 @@ def project_show(ctx, name): confirmation_prompt=True, help='user password') @click.option('--projects', - prompt=True, + prompt="Comma separate list of projects", multiple=True, + callback=lambda ctx, param, value: ''.join(value).split(',') if all(len(x)==1 for x in value) else value, help='list of project ids that the user belongs to') #@click.option('--description', # default='no description', diff --git a/osmclient/sol005/user.py b/osmclient/sol005/user.py index ad8027d..29635f9 100644 --- a/osmclient/sol005/user.py +++ b/osmclient/sol005/user.py @@ -39,6 +39,8 @@ class User(object): def create(self, name, user): """Creates a new OSM user """ + if len(user["projects"]) == 1: + user["projects"] = user["projects"][0].split(",") http_code, resp = self._http.post_cmd(endpoint=self._apiBase, postfields_dict=user) #print('HTTP CODE: {}'.format(http_code)) -- 2.25.1