示例#1
0
def list():
    users = User.all()
    print_bool = lambda boolean: 'Yes' if boolean else 'No'
    data = [['Username', 'Email', 'Created At', 'Verified', 'Enabled']]
    for user in users:
        data.append([user.username, 
                     user.email,
                     user.created_at.strftime('%A %B %d %Y'),
                     print_bool(user.verified),
                     print_bool(user.enabled)])

    col_width = max(len(word) for row in data for word in row) + 2 # padding
    print '\n'
    for row in data:
        print "".join(word.ljust(col_width) for word in row)
示例#2
0
def login():
    'Login view'
    form = LoginForm()
    invalid_login = False
    if form.validate_on_submit():
        user = User.get_user(form.username.data)
        if user and user.check_password(form.password.data):
            login_user(user)
            return redirect(app.config['LOGIN_REDIRECT'])
        else:
            invalid_login = True
        

    return render_template('spirits/login.jinja', form=form, 
                                                  invalid_login=invalid_login)
示例#3
0
def create(username, email, password, verified=True, enabled=True):
    'Create a User'
    user = User(username, email, password)  
    user.verified = verified
    user.enabled = enabled
    user.save()