Add purchases and uses pages
This commit is contained in:
45
webui.py
45
webui.py
@ -8,7 +8,7 @@ Web User Interface for InvMan
|
||||
# Imports
|
||||
from flask import Flask, render_template, request
|
||||
|
||||
from libdb import Session, Product, ProductQuantity
|
||||
from libdb import Session, Product, ProductQuantity, Purchase, Use
|
||||
|
||||
|
||||
app = Flask(__name__) # app is the Flask app
|
||||
@ -29,14 +29,53 @@ def products_quantities_page():
|
||||
"""Route for the quantities page"""
|
||||
session = Session()
|
||||
query = session.query(ProductQuantity.product_upc,
|
||||
ProductQuantity.quantity, ProductQuantity.location)
|
||||
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()
|
||||
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)
|
||||
|
||||
|
||||
@app.route("/ui/purchases")
|
||||
def products_purchases_page():
|
||||
"""Route for the purchases page"""
|
||||
session = Session()
|
||||
query = session.query(Purchase.id, Purchase.product_upc,
|
||||
Purchase.quantity, Purchase.date, Purchase.location)
|
||||
if "location" in request.args:
|
||||
searchloc = request.args['location']
|
||||
if len(request.args['location']) > 0:
|
||||
data = query.filter(Purchase.location ==
|
||||
request.args['location']).all()
|
||||
else:
|
||||
data = query.all()
|
||||
else:
|
||||
searchloc = ""
|
||||
data = query.all()
|
||||
return render_template("ui/purchases.html", data=data, searchloc=searchloc)
|
||||
|
||||
|
||||
@app.route("/ui/uses")
|
||||
def products_uses_page():
|
||||
"""Route for the uses page"""
|
||||
session = Session()
|
||||
query = session.query(Use.id, Use.product_upc,
|
||||
Use.quantity, Use.date, Use.location)
|
||||
if "location" in request.args:
|
||||
searchloc = request.args['location']
|
||||
if len(request.args['location']) > 0:
|
||||
data = query.filter(Use.location ==
|
||||
request.args['location']).all()
|
||||
else:
|
||||
data = query.all()
|
||||
else:
|
||||
searchloc = ""
|
||||
data = query.all()
|
||||
return render_template("ui/uses.html", data=data, searchloc=searchloc)
|
||||
|
Reference in New Issue
Block a user