From 82f37f4b2502cde87ffb5ea81d7c0f76ce665915 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Mon, 5 Oct 2020 20:10:43 -0500 Subject: [PATCH] Add products and quantities pages --- templates/ui/products.html | 25 +++++++++++++++++++++++++ templates/ui/quantities.html | 19 +++++++++++++++++++ webui.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 templates/ui/products.html create mode 100644 templates/ui/quantities.html create mode 100644 webui.py diff --git a/templates/ui/products.html b/templates/ui/products.html new file mode 100644 index 0000000..5aae140 --- /dev/null +++ b/templates/ui/products.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + {% for upc, brand, name, size, sizeunit, description in data %} + + + + + + + + + {% endfor %} +
UPCBrandNameSizeSize UnitDescription
{{ upc }} {{ brand }} {{ name }} {{ size }} {{ sizeunit }} {{ description }}
+ + \ No newline at end of file diff --git a/templates/ui/quantities.html b/templates/ui/quantities.html new file mode 100644 index 0000000..6023cf3 --- /dev/null +++ b/templates/ui/quantities.html @@ -0,0 +1,19 @@ + + + + + + + + + + {% for upc, quantity, location in data %} + + + + + + {% endfor %} +
UPCQuantityLocation
{{ upc }} {{ quantity }} {{ location }}
+ + \ No newline at end of file diff --git a/webui.py b/webui.py new file mode 100644 index 0000000..e6f0a2b --- /dev/null +++ b/webui.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +""" +InvMan Web UI + +Web User Interface for InvMan +""" + +# Imports +from flask import Flask, render_template + +from libdb import Session, Product, ProductQuantity + + +app = Flask(__name__) # app is the Flask app + + +@app.route("/ui/products") +def products_list_page(): + """Route for the products page""" + session = Session() + data = session.query( + Product.upc, Product.brand, Product.name, + Product.size, Product.sizeunit, Product.description).all() + return render_template("ui/products.html", data=data) + + +@app.route("/ui/quantities") +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)