def item_detail(id): with DBContextManager(db) as db_obj: sql = "select * from products where id = ?" request = db_obj.execute(sql, [id]) item = request.fetchall()[0] specification = item[6].replace('\n', '<br>') return render_template("item.html", item=item, specification=specification)
def admin_home(): with DBContextManager(db) as db_obj: request = db_obj.execute("select category_name, id from categories") result = request.fetchall() categories_dict = {key: value for (key, value) in result} return render_template("admin.html", store_title=store_title, categories_dict=categories_dict)
def products_by_id(id, category): with DBContextManager(db) as db_obj: sql = "select name, id from products where category = ? and (quantity_on_sale or quantity_in_stock) > 0" request = db_obj.execute(sql, [id]) result = request.fetchall() products = {key: value for (key, value) in result} return render_template("products.html", category=category, products=products)
def goods_by_id(id, category): with DBContextManager(db) as db_obj: sql = "select name, id from goods where category = ? and (for_sale_count or on_stock_count) > 0" request = db_obj.execute(sql, [id]) result = request.fetchall() goods = {key: value for (key, value) in result} return render_template("goods.html", category=category, store_title=store_title, goods=goods)