@click.command() @click.option('--screen_name', prompt=True) @click.option('--email_address', prompt=True) @click.option('--password', prompt=True, hide_input=True) def execute(screen_name, email_address, password): click.echo('Creating user "{}" ... '.format(screen_name), nl=False) user = _create_user(screen_name, email_address) password_service.create_password_hash(user.id, password) click.secho('done.', fg='green') def _create_user(screen_name, email_address): try: user = user_service.build_user(screen_name, email_address) except ValueError as e: raise click.UsageError(e) user.enabled = True db.session.add(user) db.session.commit() return user if __name__ == '__main__': config_filename = get_config_filename_from_env_or_exit() with app_context(config_filename): execute()
:License: Modified BSD, see LICENSE for details. """ import click from byceps.database import db from bootstrap.helpers import get_user, promote_orga from bootstrap.util import app_context, get_config_name_from_env from bootstrap.validators import validate_brand @click.command() @click.argument('brand', callback=validate_brand) @click.argument('screen_name') def execute(brand, screen_name): click.echo('Promoting user "{}" to orga for brand {} ... ' .format(screen_name, brand.title), nl=False) user = get_user(screen_name) promote_orga(brand, user) db.session.commit() click.secho('done.', fg='green') if __name__ == '__main__': config_name = get_config_name_from_env() with app_context(config_name): execute()