Fixed all pep8 warnings
This commit is contained in:
@@ -42,10 +42,13 @@ def index():
|
||||
products = database.read_all()
|
||||
|
||||
# No Products visible
|
||||
if products == None:
|
||||
if products is None:
|
||||
flash("No Products available")
|
||||
|
||||
return render_template('index.html', content="content.html", products=products)
|
||||
return render_template('index.html',
|
||||
content="content.html",
|
||||
products=products
|
||||
)
|
||||
|
||||
# Loads a given product category page
|
||||
|
||||
@@ -56,17 +59,21 @@ def category(category: str):
|
||||
|
||||
# Check to see if there is a custome search term
|
||||
search_term = request.args.get("search", type=str)
|
||||
if search_term != None:
|
||||
if search_term is not 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:
|
||||
if products is None:
|
||||
flash(f"No Products available in {category}")
|
||||
|
||||
return render_template('index.html', content="content.html", products=products, category=category)
|
||||
return render_template('index.html',
|
||||
content="content.html",
|
||||
products=products,
|
||||
category=category
|
||||
)
|
||||
|
||||
# Loads a given product based on ID
|
||||
|
||||
@@ -82,13 +89,13 @@ def display_add_product():
|
||||
user_id = session.get('user_id')
|
||||
|
||||
# User must be logged in to view this page
|
||||
if user_id == None:
|
||||
if user_id is None:
|
||||
flash("Please Login to view this page")
|
||||
return redirect('/login')
|
||||
|
||||
db = UserController()
|
||||
user = db.read_id(user_id)
|
||||
if user == None or user.role != "Seller":
|
||||
if user is None or user.role != "Seller":
|
||||
flash("You must be logged in as a Seller to view this page")
|
||||
return redirect('/')
|
||||
|
||||
@@ -101,20 +108,20 @@ def add_product():
|
||||
user_id = session.get('user_id')
|
||||
|
||||
# User must be logged in to view this page
|
||||
if user_id == None:
|
||||
if user_id is None:
|
||||
flash("Please Login to view this page")
|
||||
return redirect('/login', code=302)
|
||||
|
||||
db = UserController()
|
||||
user = db.read_id(user_id)
|
||||
if user == None or user.role != "Seller":
|
||||
if user is None or user.role != "Seller":
|
||||
flash("You must be logged in as a Seller to perform this action")
|
||||
return redirect('/', code=302)
|
||||
|
||||
file = request.files.get('image')
|
||||
|
||||
# Ensure that the correct file type is uploaded
|
||||
if file == None or not allowed_file(file.filename):
|
||||
if file is None or not allowed_file(file.filename):
|
||||
flash("Invalid File Uploaded")
|
||||
return redirect("/add")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user