diff --git a/controllers/web/product.py b/controllers/web/product.py index 25f1800..5a3bec5 100644 --- a/controllers/web/product.py +++ b/controllers/web/product.py @@ -50,7 +50,10 @@ def category(category: str): # No Products visible if products is None: - flash(f"No Products available. Try expanding your search criteria.") + flash( + f"No Products available. Try expanding your search criteria.", + "warning" + ) return render_template( 'index.html', @@ -68,7 +71,7 @@ def id(id: int): # Check that a valid product was returned if product is None: - flash(f"No Product available with id {id}") + flash(f"No Product available with id {id}", "warning") return redirect("/") print(product.name) @@ -86,7 +89,7 @@ def display_add_product(): # User needs to be logged in as a seller to view this page if not is_role("Seller"): - flash("You must be logged in as a seller to view this page!") + flash("You must be logged in as a seller to view this page!", "error") return redirect("/") return render_template('index.html', content='new_product.html') @@ -101,7 +104,7 @@ def add_product(): # User needs to be logged in as a seller to view this page if not is_role("Seller"): - flash("You must be logged in as a seller to view this page!") + flash("You must be logged in as a seller to view this page!", "error") return redirect("/") file = request.files.get('image') @@ -132,14 +135,14 @@ def update_product(id: int): # User needs to be logged in as a seller to view this page if not is_role("Seller"): - flash("You must be logged in as a seller to view this page!") + flash("You must be logged in as a seller to view this page!", "error") return redirect("/") db = ProductController() product = db.read_id(id) if product.sellerID != user_id: - flash("This product does not belong to you!") + flash("This product does not belong to you!", "error") return redirect("/ownproducts") # Save new image file @@ -158,7 +161,7 @@ def update_product(id: int): product.quantityAvailable = request.form.get('quantity') db.update(product) - flash("Product successfully updated") + flash("Product successfully updated", 'notice') return redirect(f"/products/{product.id}") @@ -169,14 +172,14 @@ def display_own_products(): # User must be logged in as seller to view page if not is_role("Seller"): - flash("You must be logged in as a seller to view this page!") + flash("You must be logged in as a seller to view this page!", "error") return redirect("/") db = ProductController() products = db.read_user(user_id) if products is None: - flash("You don't currently have any products for sale.") + flash("You don't currently have any products for sale.", "info") return render_template( 'index.html', diff --git a/controllers/web/user.py b/controllers/web/user.py index 7b15240..60bd316 100644 --- a/controllers/web/user.py +++ b/controllers/web/user.py @@ -31,13 +31,13 @@ def login(): # No user found if user is None: error = "No user found with the username " + request.form['username'] - flash(error) + flash(error, 'warning') return redirect("/login") # Incorrect Password if sha512(request.form['password'].encode()).hexdigest() != user.password: error = "Incorrect Password" - flash(error) + flash(error, 'warning') return redirect("/login") session['user_id'] = user.id @@ -59,7 +59,7 @@ def signup(): # User already exists if database.read(request.form['username']) is not None: error = "User, " + request.form['username'] + " already exists" - flash(error) + flash(error, 'warning') return redirect("/signup") # Signup as Seller or Customer diff --git a/templates/header.html b/templates/header.html index 850d9dd..d6b0407 100644 --- a/templates/header.html +++ b/templates/header.html @@ -35,12 +35,12 @@ -{% with messages = get_flashed_messages()%} +{% with messages = get_flashed_messages(with_categories=true)%} {% if messages %} - {% for message in messages %} + {% for category, message in messages %}