Beispiel #1
0
def add_warehouse():
    store = Store.get(Store.name == request.form["store_select"])
    w = Warehouse(location=request.form["location"], store=store)
    try:
        w.save()
        flash("Successfully saved!")
        return redirect("/")
    except:
        flash("Warehouse exists! Trash!")
        return redirect("/warehouse")
Beispiel #2
0
def warehouse_create():
    location = request.form.get('warehouse_location')
    store_id = request.form.get('store_id')

    store =Store.get(Store.id == store_id)
    w = Warehouse(location=location, store=store)

    if w.save():
        return redirect(url_for('warehouse'))
    else:
        return render_template('warehouse.html')
def create_warehouse():
    location = request.form['location']
    store_id = Store.get(Store.name == request.form['store_name'])
    warehouse = Warehouse(location=location, store_id=store_id)

    if warehouse.save():
        flash('Succesfully created warehouse!', "success")
        return render_template('index.html')
    else:
        flash('Failed to create warehouse', "danger")
        return redirect(url_for('show_warehouse'))
Beispiel #4
0
def update_store(id):
    old_name = Store.get(id=id).name
    new_store_name = Store.update(name=request.form.get("name")).where(
        Store.name == old_name)

    if new_store_name.execute():
        flash(f"Successfully updated")
        # have to pass in id as id, since def show_store(id):
        return redirect(url_for("show_store", id=id))
    else:
        flash("That name is already taken")
        return render_template("show_store.html")
Beispiel #5
0
def relationOneToOne():

    #creando usuario
    user = User.create(username='******',
                       password='******',
                       email='*****@*****.**')
    #crenado su tienda se puede ocupar user_id = 1
    store = Store.create(name='tienda dayana',
                         address='sin direccion',
                         user=user)

    tienda_facil = Store.get(Store.user_id == 1)
    print(tienda_facil)
    #retorna la relacion con el usuario
    print(tienda_facil.user.username)
Beispiel #6
0
def relationOneToMany():
    #creando usuario
    user = User.create(username='******',
                       password='******',
                       email='*****@*****.**')
    #crenado su tienda se puede ocupar user_id = 1
    store1 = Store.create(name='tienda zoila',
                          address='sin direccion',
                          user=user)
    store2 = Store.create(name='tienda villatoro',
                          address='sin direccion',
                          user=user)

    #viendo la info de la primera tienda
    user = User.get(User.id == 1)
    print(user)

    for store in user.stores:
        print(store)

    store1 = Store.get(Store.id == 1)
    print(store1.user)
Beispiel #7
0
def show_store(id):
    sname = Store.get(id=id)
    return render_template('show_store.html', sname=sname)