diff --git a/templates/ui/purchases.html b/templates/ui/purchases.html
new file mode 100644
index 0000000..dfffa73
--- /dev/null
+++ b/templates/ui/purchases.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+ ID |
+ UPC |
+ Quantity |
+ Date |
+ Location |
+
+ {% for id, upc, quantity, date, location in data %}
+
+ {{ id }} |
+ {{ upc }} |
+ {{ quantity }} |
+ {{ date }} |
+ {{ location }} |
+
+ {% endfor %}
+
+
+
\ No newline at end of file
diff --git a/templates/ui/uses.html b/templates/ui/uses.html
new file mode 100644
index 0000000..8fa1fc0
--- /dev/null
+++ b/templates/ui/uses.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+ ID |
+ UPC |
+ Quantity |
+ Date |
+ Location |
+
+ {% for id, upc, quantity, date, location in data %}
+
+ {{ id }} |
+ {{ upc }} |
+ {{ quantity }} |
+ {{ date }} |
+ {{ location }} |
+
+ {% endfor %}
+
+
+
\ No newline at end of file
diff --git a/webui.py b/webui.py
index ebf021e..4065491 100644
--- a/webui.py
+++ b/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)