Beispiel #1
0
def get_electronics():
    if request.method == "POST":
        if "add_to_cart" in request.form:
            item_id = request.form["add_to_cart"]
            cart.add_to_cart(item_id)
        if "remove_from_cart" in request.form:
            item_id = request.form["remove_from_cart"]
            cart.remove_from_cart(item_id)
    return render_template(
        "/listing.html",
        items=Database.get_item_by_category(Category.ELECTRONIC),
        listing_title="Electronics",
        cart=cart,
    )
Beispiel #2
0
def get_furniture():
    if request.method == "POST":
        if "add_to_cart" in request.form:
            item_id = request.form["add_to_cart"]
            cart.add_to_cart(item_id)
        if "remove_from_cart" in request.form:
            item_id = request.form["remove_from_cart"]
            cart.remove_from_cart(item_id)
    return render_template(
        "/listing.html",
        items=Database.get_item_by_category(Category.FURNITURE),
        listing_title="Furniture",
        cart=cart,
    )
Beispiel #3
0
def get_clothes():
    if request.method == "POST":
        if "add_to_cart" in request.form:
            item_id = request.form["add_to_cart"]
            cart.add_to_cart(item_id)
        if "remove_from_cart" in request.form:
            item_id = request.form["remove_from_cart"]
            cart.remove_from_cart(item_id)
    return render_template(
        "/listing.html",
        items=Database.get_item_by_category(Category.CLOTHING),
        listing_title="Clothes",
        cart=cart,
    )
Beispiel #4
0
def get_sports():
    if request.method == "POST":
        if "add_to_cart" in request.form:
            item_id = request.form["add_to_cart"]
            cart.add_to_cart(item_id)
        if "remove_from_cart" in request.form:
            item_id = request.form["remove_from_cart"]
            cart.remove_from_cart(item_id)
    return render_template(
        "/listing.html",
        items=Database.get_item_by_category(Category.SPORTS_GEAR),
        listing_title="Sports",
        cart=cart,
    )