Products can now be searched using search term

This commit is contained in:
2024-01-15 21:47:18 +00:00
parent 40d7469321
commit 36a04d58e1
4 changed files with 36 additions and 7 deletions

View File

@ -1,6 +1,6 @@
from flask import Blueprint
from flask import render_template, session, flash
from flask import render_template, session, flash, request
from controllers.database.product import ProductController
from controllers.database.category import CategoryController
@ -29,9 +29,15 @@ def index():
# Loads a given product category page
@blueprint.route('/<string:category>')
def category(category: str):
print(category)
database = ProductController()
products = database.read_all(category)
# Check to see if there is a custome search term
search_term = request.args.get("search", type=str)
if search_term != None:
print(f"Search Term {search_term}")
products = database.read_all(category, search_term)
else:
products = database.read_all(category)
# No Products visible
if products == None: