def delete_restaurant(restaurant_id): if "username" not in login_session: return redirect(url_for("login")) if request.method == "GET": restaurant = crud.get_restaurant(restaurant_id) return render_template("/restaurants/delete_restaurant.html", restaurant=restaurant) if request.method == "POST": crud.delete_restaurant(restaurant_id) flash("Restaurant Successfully Deleted") return redirect(url_for("show_restaurants"))
def edit_restaurant(restaurant_id): if "username" not in login_session: return redirect(url_for("login")) form = RestaurantForm() restaurant = crud.get_restaurant(restaurant_id) if request.method == "GET": # Set default values form.name.data = restaurant.name form.description.data = restaurant.description form.address.data = restaurant.address if request.method == "POST" and form.validate_on_submit(): name = form.name.data description = form.description.data address = form.address.data image = form.image.data crud.edit_restaurant(restaurant_id, name, description, address, image) flash("Restaurant Successfully Edited") return redirect(url_for("show_restaurants")) return render_template("/restaurants/edit_restaurant.html", restaurant=restaurant, form=form)
def show_menu(restaurant_id): menu = crud.get_menu_items(restaurant_id) restaurant = crud.get_restaurant(restaurant_id) return render_template('/menu/menu.html', menu=menu, restaurant=restaurant)