Skip to content

Commit

Permalink
User add fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Sivakov committed Nov 14, 2019
1 parent 7c3f441 commit 15d8f46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion ckan/cli/cli.py
Expand Up @@ -16,7 +16,8 @@
tracking,
minify,
less,
generate
generate,
user
)

from ckan.config.middleware import make_app
Expand Down Expand Up @@ -56,3 +57,4 @@ def ckan(ctx, config, *args, **kwargs):
ckan.add_command(minify.minify)
ckan.add_command(less.less)
ckan.add_command(generate.generate)
ckan.add_command(user.user)
11 changes: 5 additions & 6 deletions ckan/cli/user.py
Expand Up @@ -40,12 +40,11 @@ def add_user(ctx, username, args):
)

# Required
while u'@' not in data_dict.get(u'email', ''):
error_shout(u'Error: Invalid email address')
data_dict['email'] = click.prompt(u'Email address: ').strip()
if 'email' not in data_dict:
data_dict['email'] = click.prompt(u'Email address ').strip()

if u'password' not in data_dict:
data_dict['password'] = click.prompt(u'Password: ', hide_input=True,
data_dict['password'] = click.prompt(u'Password ', hide_input=True,
confirmation_prompt=True)

# Optional
Expand All @@ -54,7 +53,7 @@ def add_user(ctx, username, args):
sys.getfilesystemencoding()
)

pprint(u'Creating user: %r' % username)
# pprint(u'Creating user: %r' % username)

try:
import ckan.logic as logic
Expand All @@ -73,7 +72,7 @@ def add_user(ctx, username, args):
flask_app = ctx.obj.app.apps[u'flask_app']._wsgi_app
with flask_app.test_request_context():
user_dict = logic.get_action('user_create')(context, data_dict)
click.secho(user_dict)
click.secho(u"Successfully created user: %s" % user_dict['name'], fg=u'green', bold=True)
except logic.ValidationError as e:
error_shout(e)

Expand Down

0 comments on commit 15d8f46

Please sign in to comment.