def showMenu(restaurant_id):
    """ Show Menu of a Restaurant"""
    restaurant = fpcrud.get_restaurant_byid(restaurant_id)
    items = fpcrud.getMenuItemByRestaurant(restaurant_id)
    return render_template('menu.html',
                           restaurant_id=restaurant_id,
                           restaurant=restaurant,
                           items=items)
def deleteRestaurant(restaurant_id, methods=['GET', 'POST']):
    """ View to delete a Restaurant"""
    if request.method == 'GET':
        restaurant = fpcrud.get_restaurant_byid(restaurant_id)
        return render_template('deleterestaurant.html',
                               restaurant=restaurant,
                               restaurant_id=restaurant_id)
    if request.method == 'POST':
        fpcrud.delete_restaurant(restaurant_id)
        return redirect(url_for('showRestaurants'))
def editRestaurant(restaurant_id):
    """ View to edit a existing Restaurant"""
    if request.method == 'GET':
        restaurant = fpcrud.get_restaurant_byid(restaurant_id)
        return render_template('editrestaurant.html',
                               restaurant=restaurant,
                               restaurant_id=restaurant_id)
    if request.method == 'POST':
        fpcrud.edit_restaurant(restaurant_id, request.form['name'])
        return redirect(url_for('showRestaurants'))
def deleteMenuItem(restaurant_id, menu_id):
    """ Deleting a item of the menu of a restaurant"""
    restaurant = fpcrud.get_restaurant_byid(restaurant_id)
    item = fpcrud.getMenuItemById(menu_id)
    if request.method == 'GET':
        return render_template('deletemenuitem.html',
                               item=item,
                               restaurant_id=restaurant_id,
                               menu_id=menu_id)
    if request.method == 'POST':
        fpcrud.deleteMenuItem(menu_id)
    return redirect(url_for('showMenu', restaurant_id=restaurant_id))
def editMenuItem(restaurant_id, menu_id):
    """ Editing a item of the menu of a restaurant"""
    restaurant = fpcrud.get_restaurant_byid(restaurant_id)
    item = fpcrud.getMenuItemById(menu_id)
    if request.method == "GET":
        return render_template('editmenuitem.html',
                               item=item,
                               restaurant_id=restaurant_id,
                               menu_id=menu_id)
    if request.method == "POST":
        fpcrud.editMenuItem(
            menu_id,
            request.form["name"],
            request.form["course"],
            request.form["description"],
            request.form["price"],
        )
        return redirect(
            url_for('showMenu', restaurant_id=restaurant_id, item=item))