From df6e64afc3a987edeb3565050a731e03f458ddb1 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Mon, 5 Oct 2020 23:16:36 -0500 Subject: [PATCH] Add search box for location to quantities page --- templates/ui/quantities.html | 5 +++++ webui.py | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/templates/ui/quantities.html b/templates/ui/quantities.html index 6023cf3..829aaac 100644 --- a/templates/ui/quantities.html +++ b/templates/ui/quantities.html @@ -1,6 +1,11 @@ +
+ + +
+ Clear Search diff --git a/webui.py b/webui.py index e6f0a2b..ebf021e 100644 --- a/webui.py +++ b/webui.py @@ -6,7 +6,7 @@ Web User Interface for InvMan """ # Imports -from flask import Flask, render_template +from flask import Flask, render_template, request from libdb import Session, Product, ProductQuantity @@ -28,6 +28,15 @@ def products_list_page(): def products_quantities_page(): """Route for the quantities page""" session = Session() - data = session.query(ProductQuantity.product_upc, - ProductQuantity.quantity, ProductQuantity.location).all() - return render_template("ui/quantities.html", data=data) + 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)
UPC