Exemplo n.º 1
0
def delete_item(order_id, lineitem_id, username):
    Orders.delete_from_basket(order_id, lineitem_id)
    session['basket_data'] = Item.basket_item_data(
        Customer.get_id_by_name(username))
    session['order_data'] = Lineitem.get_singleorder_list(
        Customer.get_id_by_name(username))
    session['total'] = Sale.get_total(username)
    session['discount_total'] = Sale.get_discount_total(username)
    session['overthreshold_total'] = Sale.get_overthreshold_total(username)
    return redirect(url_for('basket'))
Exemplo n.º 2
0
def checkout(username):
    sale = Sale(username)
    sale.checkout()
    session['basket_data'] = Item.basket_item_data(
        Customer.get_id_by_name(username))
    session['order_data'] = Lineitem.get_singleorder_list(
        Customer.get_id_by_name(username))
    session['total'] = 0
    session['discount_total'] = Sale.get_discount_total(username)
    session['overthreshold_total'] = Sale.get_overthreshold_total(username)
    return redirect(url_for('payment'))
Exemplo n.º 3
0
def add_to_basket():
    form = request.form
    username = form.get('username')
    item_id = form.get('item_id')
    if not username:
        return redirect(url_for('index_to_login'))
    sale = Sale(username)
    sale.add_item(item_id)
    session['basket_data'] = Item.basket_item_data(
        Customer.get_id_by_name(username))
    session['order_data'] = Lineitem.get_singleorder_list(
        Customer.get_id_by_name(username))
    session['total'] = Sale.get_total(username)
    session['discount_total'] = Sale.get_discount_total(username)
    session['overthreshold_total'] = Sale.get_overthreshold_total(username)
    return redirect(url_for('customer_index'))
Exemplo n.º 4
0
def alteruser(user_id):
    form = request.form
    username = form.get('username')
    password = form.get('password')
    nname = form.get('nickname')
    telephone = form.get('phone')
    address = form.get('address')
    print(user_id)
    if not Customer.is_repeated(username):
        Customer.alterusers(user_id, username, password, nname, telephone,
                            address)
        session['name'] = username
        session['basket_data'] = Item.basket_item_data(
            Customer.get_id_by_name(username))
        session['order_data'] = Lineitem.get_singleorder_list(
            Customer.get_id_by_name(username))
        session['customer_data'] = Customer.query()
        return redirect(url_for('customer_index'))
    else:
        flash('用户名重复')
        return redirect(url_for('customer_index'))
Exemplo n.º 5
0
def login():
    form = request.form
    username = form.get('name')
    password = form.get('pwd')
    role = form.get('select')
    if Customer.is_valid(username, password):
        session['name'] = username
        session['userId'] = Customer.get_id_by_name(username)
        if role == u'顾客':
            session['minute'] = Sale.getMinute(username)
            session['id'] = Customer.get_id_by_name(username)
            session['basket_data'] = Item.basket_item_data(
                Customer.get_id_by_name(username))
            session['order_data'] = Lineitem.get_singleorder_list(
                Customer.get_id_by_name(username))
            session['total'] = Sale.get_total(username)
            session['discount_total'] = Sale.get_discount_total(username)
            session['overthreshold_total'] = Sale.get_overthreshold_total(
                username)
            return redirect(url_for('customer_index'))
        else:
            flash('账号或密码错误')
            return render_template('login.html')
    elif Seller.is_valid(username, password):
        session['name'] = username
        if role == u'卖家':
            return redirect(url_for('seller_index'))
        else:
            flash('账号或密码错误')
            return render_template('payment.html')
    elif Admin.is_valid(username, password):
        session['name'] = username
        if role == u'管理员':
            return redirect(url_for('admin_index'))
        else:
            flash('账号或密码错误')
            return render_template('orders.html')
    else:
        flash('该用户不存在,请重新输入')
        return render_template('login.html')