def create_warehouse(): location = request.form.get('location') store_select = request.form.get('store_select') try: Warehouse.create(location = location, store = store_select) except: print("error") return redirect(url_for('new_warehouse', location = location, store_select = store_select))
def warehouse(): if request.method == 'POST': store = request.form['store_list'] location = request.form['warehouse_location'] new_warehouse = Warehouse.create(location=location, store=store) new_warehouse.save() flash("Warehouse created", "success") return redirect(url_for('warehouse')) else: # result = Store.select(Store.name, fn.COUNT(Warehouse.store.id == Store.id)).join(Warehouse).group_by(Store.name).where(Store.id == Warehouse.store.id) warehouse_list = Warehouse.select() store_list = Store.select() return render_template('warehouse.html', warehouse_list=warehouse_list, store_list=store_list)
def warehouse_add(): print(request.form["store_id"]) store = Store.get_by_id(request.form["store_id"]) Warehouse.create(location=request.form.get("warehouse_location"),store=store) return redirect("/warehouse")