예제 #1
0
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"
예제 #2
0
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"
예제 #3
0
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"
예제 #4
0
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."
예제 #5
0
def menuItemJSON(restaurant_id, menu_id):
    return jsonify(
        MenuItem=database_query.getMenuItem(mySession, menu_id).serialize)