def deleteMenuItem(restaurant_id, menu_id): if request.method == 'POST': if database_query.deleteMenuItem(mySession, menu_id): return redirect(url_for("restaurantMenu", restaurant_id = restaurant_id)) else: item = database_query.getMenuItem(mySession, menu_id) if item: return render_template("deletemenuitem.html", item = item ) return "Menu item cannot be found"
def editMenuItem(restaurant_id, menu_id): if request.method == 'POST': if database_query.editMenuItem(mySession, menu_id, request.form["name"]): return redirect(url_for("restaurantMenu", restaurant_id = restaurant_id)) else: i = database_query.getMenuItem(mySession, menu_id) if i: return render_template("editmenuitem.html", restaurant_id = restaurant_id, menu_id = menu_id, menu_name = i.name) return "Menu item cannot be found"
def deleteMenuItem(restaurant_id, menu_id): item = database_query.getMenuItem(mySession, menu_id) if item: if request.method == 'GET': return render_template("deletemenuitem.html", item=item) elif request.method == 'POST': database_query.deleteMenuItem(mySession, menu_id) flash("menu item is deleted!") return redirect( url_for("restaurantMenu", restaurant_id=restaurant_id)) return "cannot find item to delete"
def editMenuItem(restaurant_id, menu_id): if request.method == 'GET': print("hoho GET") return render_template("editmenuitem.html", restaurant_id=restaurant_id, menu_id=menu_id, menu_name=database_query.getMenuItem( mySession, menu_id).name) elif request.method == 'POST': if database_query.editMenuItem(mySession, menu_id, request.form["name"]): flash("menu item %s is edited!" % request.form["name"]) return redirect( url_for("restaurantMenu", restaurant_id=restaurant_id)) return "Menu item cannot be added."
def menuItemJSON(restaurant_id, menu_id): return jsonify( MenuItem=database_query.getMenuItem(mySession, menu_id).serialize)