Add purchases and uses pages
This commit is contained in:
parent
fa1361e13f
commit
175c464f66
29
templates/ui/purchases.html
Normal file
29
templates/ui/purchases.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<form action="./purchases">
|
||||||
|
<input type="text" placeholder="Location" name="location" />
|
||||||
|
<input type="submit" />
|
||||||
|
<br>
|
||||||
|
<input type="reset" value="Reset" onclick="parent.location='./purchases'" />
|
||||||
|
</form>
|
||||||
|
<table border=1>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<td>UPC</td>
|
||||||
|
<td>Quantity</td>
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Location</td>
|
||||||
|
</tr>
|
||||||
|
{% for id, upc, quantity, date, location in data %}
|
||||||
|
<tr>
|
||||||
|
<th> {{ id }}</th>
|
||||||
|
<th> {{ upc }} </th>
|
||||||
|
<td> {{ quantity }} </td>
|
||||||
|
<td> {{ date }}</td>
|
||||||
|
<td> {{ location }} </td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
29
templates/ui/uses.html
Normal file
29
templates/ui/uses.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<form action="./uses">
|
||||||
|
<input type="text" placeholder="Location" name="location" />
|
||||||
|
<input type="submit" />
|
||||||
|
<br>
|
||||||
|
<input type="reset" value="Reset" onclick="parent.location='./uses'" />
|
||||||
|
</form>
|
||||||
|
<table border=1>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<td>UPC</td>
|
||||||
|
<td>Quantity</td>
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Location</td>
|
||||||
|
</tr>
|
||||||
|
{% for id, upc, quantity, date, location in data %}
|
||||||
|
<tr>
|
||||||
|
<th> {{ id }}</th>
|
||||||
|
<th> {{ upc }} </th>
|
||||||
|
<td> {{ quantity }} </td>
|
||||||
|
<td> {{ date }}</td>
|
||||||
|
<td> {{ location }} </td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
45
webui.py
45
webui.py
@ -8,7 +8,7 @@ Web User Interface for InvMan
|
|||||||
# Imports
|
# Imports
|
||||||
from flask import Flask, render_template, request
|
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
|
app = Flask(__name__) # app is the Flask app
|
||||||
@ -29,14 +29,53 @@ def products_quantities_page():
|
|||||||
"""Route for the quantities page"""
|
"""Route for the quantities page"""
|
||||||
session = Session()
|
session = Session()
|
||||||
query = session.query(ProductQuantity.product_upc,
|
query = session.query(ProductQuantity.product_upc,
|
||||||
ProductQuantity.quantity, ProductQuantity.location)
|
ProductQuantity.quantity, ProductQuantity.location)
|
||||||
if "location" in request.args:
|
if "location" in request.args:
|
||||||
searchloc = request.args['location']
|
searchloc = request.args['location']
|
||||||
if len(request.args['location']) > 0:
|
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:
|
else:
|
||||||
data = query.all()
|
data = query.all()
|
||||||
else:
|
else:
|
||||||
searchloc = ""
|
searchloc = ""
|
||||||
data = query.all()
|
data = query.all()
|
||||||
return render_template("ui/quantities.html", data=data, searchloc=searchloc)
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user