Products can now be searched using search term
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user