def deleteMenuItem(restaurant_id, menu_id):
    #item to delete
    deletedItem = RestaurantQuery.get_menu_item(menu_id)

    #if posted too, process the form
    #else just display the page and it's form
    if request.method == 'POST':
        RestaurantQuery.delete_menu_item(deletedItem.id)

         #flash message
        flash("Successfully deleted "+deletedItem.name+" from the menu")

        return redirect(url_for('menuItems', restaurant_id=restaurant_id))
    else:
        return render_template('deleteMenuItem.html', restaurant_id=restaurant_id, menu_id=menu_id, item=deletedItem)
def editMenuItem(restaurant_id, menu_id):
    #item to edit
    editedItem = RestaurantQuery.get_menu_item(menu_id)
    #if posted too, process the form
    #else just display the page and it's form
    if request.method == 'POST':
        if request.form['name']:
            editedItem.name = request.form['name']
        RestaurantQuery.edit_menu_item(editedItem.name, editedItem.id)

        #flash message
        flash("Updated "+editedItem.name)

        return redirect(url_for('menuItems', restaurant_id=restaurant_id))
    else:
        
        return render_template('editMenuItem.html', restaurant_id=restaurant_id, menu_id=menu_id, item=editedItem)
def restaurantMenuItemJSON(restaurant_id, menu_id):
    #get the menu items from the restaurant
    item = RestaurantQuery.get_menu_item(menu_id)

    return jsonify(MenuItem=[item.serialize])