示例#1
0
def add_recipe_to_cart(recipeid, userid):
    """Add ingredients from a given recipe to grocery cart."""

    recipe_ingredients = Ingredient.get_recipe_ingredients(recipeid)

    for ingredient in recipe_ingredients:
        Cart_Ingredient.create_new_cart_ingredient(session['Cart'], ingredient.ingredient_id)

    flash("You have successfully added your recipe to your grocery cart.", "cart_add")

    return redirect("/myrecipes/%d/cart/%d" % (userid, session['Cart']))
示例#2
0
def display_recipe(userid, recipeid):
    """Retrieves an individual recipe from db for display."""

    recipe = Recipe.get_recipe(recipeid)

    ingredients = Ingredient.get_recipe_ingredients(recipeid)

    recipe_hashtags = Recipe_Hashtag.get_recipe_hashtags(recipeid)

    return render_template("recipe_info.html", recipe=recipe,
                           ingredients=ingredients, recipe_hashtags=recipe_hashtags,
                           userid=userid)
示例#3
0
def add_recipe_to_cart(recipeid, userid):
    """Add ingredients from a given recipe to grocery cart."""

    recipe_ingredients = Ingredient.get_recipe_ingredients(recipeid)

    for ingredient in recipe_ingredients:
        Cart_Ingredient.create_new_cart_ingredient(session['Cart'],
                                                   ingredient.ingredient_id)

    flash("You have successfully added your recipe to your grocery cart.",
          "cart_add")

    return redirect("/myrecipes/%d/cart/%d" % (userid, session['Cart']))
示例#4
0
def display_recipe(userid, recipeid):
    """Retrieves an individual recipe from db for display."""

    recipe = Recipe.get_recipe(recipeid)

    ingredients = Ingredient.get_recipe_ingredients(recipeid)

    recipe_hashtags = Recipe_Hashtag.get_recipe_hashtags(recipeid)

    return render_template("recipe_info.html",
                           recipe=recipe,
                           ingredients=ingredients,
                           recipe_hashtags=recipe_hashtags,
                           userid=userid)
示例#5
0
def edit_recipe(userid, recipeid):
    """Get a recipe from the db, and display it so the user can edit."""

    recipe = Recipe.get_recipe(recipeid)

    ingredients = Ingredient.get_recipe_ingredients(recipeid)

    recipe_hashtags = Recipe_Hashtag.get_recipe_hashtags(recipeid)

    hashtag_list = Recipe_Hashtag.get_hashtag_names_for_recipe(recipe_hashtags)

    readable_hashtags = Hashtag.get_readable_hashtags(hashtag_list)

    recreated_hashtag_input = Hashtag.recreate_hashtag_input(readable_hashtags)

    return render_template("edit_recipe.html", recipe=recipe, ingredients=ingredients,
                           userid=userid, recreated_hashtag_input=recreated_hashtag_input)
示例#6
0
def edit_recipe(userid, recipeid):
    """Get a recipe from the db, and display it so the user can edit."""

    recipe = Recipe.get_recipe(recipeid)

    ingredients = Ingredient.get_recipe_ingredients(recipeid)

    recipe_hashtags = Recipe_Hashtag.get_recipe_hashtags(recipeid)

    hashtag_list = Recipe_Hashtag.get_hashtag_names_for_recipe(recipe_hashtags)

    readable_hashtags = Hashtag.get_readable_hashtags(hashtag_list)

    recreated_hashtag_input = Hashtag.recreate_hashtag_input(readable_hashtags)

    return render_template("edit_recipe.html",
                           recipe=recipe,
                           ingredients=ingredients,
                           userid=userid,
                           recreated_hashtag_input=recreated_hashtag_input)