示例#1
0
 def add_to_list(old_list, option):
     if not option:
         return old_list
     elif not option.price:
         return old_list
     option.price = "{:.2f}".format(float(option.price))
     if option.isLocalSeller:
         local_seller = User.get(id=option.local_seller_id)
         old_list.append({
             'seller': local_seller.username,
             'price': option.price,
             'rental': option.isRental,
             'book_type': option.type,
             'link': option.link,
             'purchaseID': option.id
         })
     else:
         old_list.append({
             'seller': option.remoteSellerName,
             'price': option.price,
             'rental': option.isRental,
             'book_type': option.type,
             'link': option.link,
             'purchaseID': option.id
         })
     return old_list
示例#2
0
def login():
    if request.method == 'POST':
        form = LoginForm(request.form)
        if form.validate():
            username = form.username.data
            password = form.password.data
            # Authenticate user
            u = User.get(username=username)
            if not u:
                flash('Incorrect Username', 'error')
                return redirect('/login')
            if u.check_password(password):
                login_user(u)
                return redirect('')
            else:
                flash('Incorrect Password', 'error')
                return redirect('/login')

    else:
        form = LoginForm()
        return render_template('login/login.html', form=form)
示例#3
0
def delete_user():
    u = User.get(id=current_user.id)
    logout_user()
    User.delete(u)
    flash('User {u} has been deleted'.format(u=u.username), 'success')
    return redirect('')