Exemple #1
0
def products():

    if request.method == 'POST':

        product_info = {}

        product_info['name'] = request.form['name']

        product_info['price'] = int(request.form['price'])

        product_info['description'] = request.form['description']
        product_info['quantity'] = int(request.form['quantity'])

        product_info['seller'] = session['username']

        if product_exists(product_info['name']):

            return "product exists"

        add_product(product_info)

        return redirect(url_for('products'))

    products = products_list()

    return render_template('products.html', products=products)
Exemple #2
0
def seller():

    if request.method == 'POST':
        product_info = {}

        product_info['name'] = request.form['name']
        product_info['price'] = int(request.form['price'])
        product_info['seller'] = session['username']
        product_info['description'] = request.form['description']

        if product_exists(product_info['name']) is False:
            add_product(product_info)
            return redirect(url_for('product'))
        return "product already exists. Go back and enter another product"
Exemple #3
0
def products():
    if request.method == 'POST':

        product_info = {}
        #import pdb;pdb.set_trace()
        product_info['name'] = request.form['name']
        product_info['price'] = int(request.form['price'])
        product_info['description'] = request.form['description']
        product_info['seller'] = session['username']

        if product_exists(product_info['name']):
            return "product exists"
        add_product(product_info)
        #return "product added! check your db"
        return redirect(url_for("home"))
    return render_template('ran.html', products=product_list())
Exemple #4
0
def add_products():

    if request.method == 'POST':

        seller = {}

        seller['pname'] = request.form['pname']
        seller['sname'] = session['username']
        seller['price'] = int(request.form['price'])
        seller['description'] = request.form['description']

        if product_exists(seller['pname']) is False:
            add_prod(seller)
            return render_template('home.html')
        return "product already exists"

    else:

        return redirect(url_for('home'))