Esempio n. 1
0
def join():
    form = JoinForm(request.form, access_code=get_setting('access_code'))
    if request.method != 'POST' or not form.validate():
        return dict(join_form=form)
    user_id = create_user(form.nickname.data, form.password.data)
    session['user_id'] = user_id
    return redirect(url_for('landing'))
Esempio n. 2
0
def generate_users(db, min_count=4, max_count=12, truncate=False):
    """
    Generates a random amount of users into the given database connection
    object. The amount of users will fall between `min_count` and `max_count`.
    If `truncate` is True, all existing users will be deleted.
    """
    logger().info('creating users')
    if truncate:
        db.truncate_table('user')
    users = []
    for user in rand_users(min_count=min_count, max_count=max_count):
        users.append(create_user(db=db, **user))
    logger().info('created %d users' % len(users))
    return users