Example #1
0
def createuser(email=None, password=None, role=None):
    """Create a user"""

    if not email:
        email = prompt("A valid email address")

    if not password:
        password = prompt_pass("Password")

    if not role:
        roles = [r.name for r in db.session.query(Role)]
        role_name = prompt_choices("Role", choices=roles,
                                   no_choice=('none', ''))
        if role_name:
            role = get_or_create(db.session, Role, name=role_name)
        else:
            role = None
    else:
        role = get_or_create(db.session, Role, name=role)

    if all([email, password]):
        user = User.createuser(db.session, email, password, roles=[role])
        db.session.commit()
    else:
        user = "******"

    print(user)
Example #2
0
def createuser(email=None, password=None, role=None):
    """Create a user"""

    if not email:
        email = prompt("A valid email address")

    if not password:
        password = prompt_pass("Password")

    if not role:
        roles = [r.name for r in db.session.query(Role)]
        role_name = prompt_choices("Role",
                                   choices=roles,
                                   no_choice=('none', ''))
        if role_name:
            role = get_or_create(db.session, Role, name=role_name)
        else:
            role = None
    else:
        role = get_or_create(db.session, Role, name=role)

    if all([email, password]):
        user = User.createuser(db.session, email, password, roles=[role])
        db.session.commit()
    else:
        user = "******"

    print(user)
Example #3
0
def createsuperuser(email=None, password=None):
    """Create a supersuer"""

    if not email:
        email = prompt("A valid email address")

    if not password:
        password = prompt_pass("Password")

    if all([email, password]):
        admin = get_or_create(db.session, Role, name='admin')
        user = User.createuser(db.session, email, password, roles=[admin])
        db.session.commit()
    else:
        user = "******"

    print(user)
Example #4
0
def createsuperuser(email=None, password=None):
    """Create a supersuer"""

    if not email:
        email = prompt("A valid email address")

    if not password:
        password = prompt_pass("Password")

    if all([email, password]):
        admin = get_or_create(db.session, Role, name='admin')
        user = User.createuser(db.session, email, password, roles=[admin])
        db.session.commit()
    else:
        user = "******"

    print(user)