Пример #1
0
def recipes_create():
    form = RecipeForm(request.form)

    if not form.validate():
        return render_template("recipes/new.html", form=form)

    recipe = Recipe(form.name.data)
    recipe.description = form.description.data
    recipe.content = form.content.data
    recipe.account_id = current_user.id

    db.session().add(recipe)
    db.session().commit()

    return redirect(url_for("recipes_index"))
Пример #2
0
def recipes_create():
    form = RecipeForm(request.form)

    if not form.validate():
        return render_template("recipes/new.html", form=form)

    r = Recipe(form.name.data)
    r.favourite = form.favourite.data
    r.account_id = current_user.id
    r.description = cleanstr(form.description.data)

    db.session().add(r)
    db.session().commit()

    return redirect(url_for("recipes_index"))