def ingredients_create(): form = IngredientForm(request.form) i = Ingredient(form.name.data) if current_user.is_admin(): i.accepted = True set_message("ainesosa lisätty") else: i.accepted = False set_message("kiitos ehdotuksestasi!") db.session().add(i) db.session().commit() form = IngredientForm() return redirect(url_for("ingredients_form"))
def ingredients_create(): form = NewIngredientForm(request.form) if not form.validate(): return render_template("ingredients/new.html", form=form) name = str(form.name.data).capitalize() i = Ingredient(name, form.unit.data) if current_user is not None: i.account_id = current_user.id if current_user.role.name == "USER+" or current_user.role.name == "ADMIN": i.accepted = True db.session().add(i) db.session().commit() return redirect(url_for("ingredients_index"))