def comment_create(recipe_id): form = CommentForm(request.form) if not form.validate(): return redirect(url_for('recipe_get', recipe_id=recipe_id)) c = Comment(form.text.data) c.account_id = current_user.id c.recipe_id = recipe_id db.session().add(c) db.session().commit() return redirect(url_for('recipe_get', recipe_id=recipe_id))
def comment_create(recipe_id): form = CommentForm(request.form) if not form.validate(): return render_template("recipes/<recipe_id>/", form=form) c = Comment(form.text.data) c.account_id = current_user.id c.recipe_id = recipe_id db.session().add(c) db.session().commit() return redirect(url_for("recipes/<recipe_id>/"))
def comment_create(recipe_id): form = CommentForm(request.form) recipe = Recipe.query.get(recipe_id) if not form.validate(): return render_template("comments/new_comment.html", form=form, recipe_id=recipe.id) comment = Comment(form.comment_text.data) comment.account_id = current_user.id comment.recipe_id = recipe.id db.session().add(comment) db.session().commit() return redirect(url_for("recipes_show_single", recipe_id=recipe.id))