Added highlighting for selected category
This commit is contained in:
@ -2,9 +2,16 @@ from flask import Blueprint
|
||||
|
||||
from flask import render_template, session, flash
|
||||
from controllers.database.product import ProductController
|
||||
from controllers.database.category import CategoryController
|
||||
|
||||
blueprint = Blueprint("products", __name__, url_prefix="/products")
|
||||
|
||||
@blueprint.context_processor
|
||||
def category_list():
|
||||
database = CategoryController()
|
||||
categories = database.read_all()
|
||||
return dict(categories=categories)
|
||||
|
||||
# Loads the front product page
|
||||
@blueprint.route('/')
|
||||
def index():
|
||||
@ -20,7 +27,15 @@ def index():
|
||||
# Loads a given product category page
|
||||
@blueprint.route('/<string:category>')
|
||||
def category(category: str):
|
||||
return "Category: " + category
|
||||
print(category)
|
||||
database = ProductController()
|
||||
products = database.read_all(category)
|
||||
|
||||
# No Products visible
|
||||
if products == None:
|
||||
flash("No Products available in " + category)
|
||||
|
||||
return render_template('index.html', content="content.html", user = session.get('user'), products = products, category = category)
|
||||
|
||||
# Loads a given product based on ID
|
||||
@blueprint.route('/<int:id>')
|
||||
|
Reference in New Issue
Block a user