Add search box for location to quantities page
This commit is contained in:
parent
82f37f4b25
commit
df6e64afc3
@ -1,6 +1,11 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
|
<form action="./quantities">
|
||||||
|
<input type="text" placeholder="Location" name="location" />
|
||||||
|
<input type="submit" />
|
||||||
|
</form>
|
||||||
|
<a href="./quantities">Clear Search</a>
|
||||||
<table border=1>
|
<table border=1>
|
||||||
<tr>
|
<tr>
|
||||||
<th>UPC</th>
|
<th>UPC</th>
|
||||||
|
17
webui.py
17
webui.py
@ -6,7 +6,7 @@ Web User Interface for InvMan
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Imports
|
# Imports
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template, request
|
||||||
|
|
||||||
from libdb import Session, Product, ProductQuantity
|
from libdb import Session, Product, ProductQuantity
|
||||||
|
|
||||||
@ -28,6 +28,15 @@ def products_list_page():
|
|||||||
def products_quantities_page():
|
def products_quantities_page():
|
||||||
"""Route for the quantities page"""
|
"""Route for the quantities page"""
|
||||||
session = Session()
|
session = Session()
|
||||||
data = session.query(ProductQuantity.product_upc,
|
query = session.query(ProductQuantity.product_upc,
|
||||||
ProductQuantity.quantity, ProductQuantity.location).all()
|
ProductQuantity.quantity, ProductQuantity.location)
|
||||||
return render_template("ui/quantities.html", data=data)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user