InvMan/webui.py

43 lines
1.2 KiB
Python
Raw Normal View History

2020-10-05 20:10:43 -05:00
#!/usr/bin/env python3
"""
InvMan Web UI
Web User Interface for InvMan
"""
# Imports
from flask import Flask, render_template, request
2020-10-05 20:10:43 -05:00
from libdb import Session, Product, ProductQuantity
app = Flask(__name__) # app is the Flask app
@app.route("/ui/products")
def products_list_page():
"""Route for the products page"""
session = Session()
data = session.query(
Product.upc, Product.brand, Product.name,
Product.size, Product.sizeunit, Product.description).all()
return render_template("ui/products.html", data=data)
@app.route("/ui/quantities")
def products_quantities_page():
"""Route for the quantities page"""
session = Session()
query = session.query(ProductQuantity.product_upc,
ProductQuantity.quantity, ProductQuantity.location)
if "location" in request.args:
searchloc = request.args['location']
if len(request.args['location']) > 0:
data = query.filter(ProductQuantity.location == request.args['location']).all()
else:
data = query.all()
else:
searchloc = ""
data = query.all()
return render_template("ui/quantities.html", data=data, searchloc=searchloc)