Updated http response codes and corrected redirects
This commit is contained in:
parent
aaaf7e4829
commit
e97631a6f4
@ -75,7 +75,7 @@ def display_add_product():
|
|||||||
# User needs to be logged in as a seller to view this page
|
# User needs to be logged in as a seller to view this page
|
||||||
if not is_role("Seller"):
|
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!")
|
||||||
return redirect("/", code=302)
|
return redirect("/", code=401)
|
||||||
|
|
||||||
return render_template('index.html', content='new_product.html')
|
return render_template('index.html', content='new_product.html')
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ def add_product():
|
|||||||
# User needs to be logged in as a seller to view this page
|
# User needs to be logged in as a seller to view this page
|
||||||
if not is_role("Seller"):
|
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!")
|
||||||
return redirect("/", code=302)
|
return redirect("/", code=401)
|
||||||
|
|
||||||
file = request.files.get('image')
|
file = request.files.get('image')
|
||||||
|
|
||||||
@ -116,17 +116,18 @@ def add_product():
|
|||||||
db = ProductController()
|
db = ProductController()
|
||||||
db.create(product)
|
db.create(product)
|
||||||
|
|
||||||
return render_template('index.html', content='new_product.html')
|
return redirect('/products/ownproducts')
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route('/ownproducts')
|
@blueprint.route('/ownproducts')
|
||||||
def display_own_products():
|
def display_own_products():
|
||||||
|
""" Display products owned by the currently logged in seller """
|
||||||
user_id = session.get('user_id')
|
user_id = session.get('user_id')
|
||||||
|
|
||||||
# User must be logged in as seller to view page
|
# User must be logged in as seller to view page
|
||||||
if not is_role("Seller"):
|
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!")
|
||||||
return redirect("/", code=302)
|
return redirect("/", code=401)
|
||||||
|
|
||||||
db = ProductController()
|
db = ProductController()
|
||||||
products = db.read_user(user_id)
|
products = db.read_user(user_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user