예제 #1
0
    def edit(self, id):
        self.form = create_form(IngredientForm, obj=self.ingredient)

        if self.ingredient.is_used:
            self.form.calorie.errors = []
            self.form.protein.errors = []
            self.form.fat.errors = []
            self.form.sugar.errors = []

        return self.template()
예제 #2
0
    def show_token(self):
        token = request.args["token"]
        form = create_form(NewPasswordForm)

        user = User.load(token, load_type="new_password_token")
        if user is None:
            flash("tento token již není platný", "error")
            return redirect(url_for("LoginView:show"))

        return template(
            "auth/new_password.html.j2", form=form, username=user.username, token=token
        )
예제 #3
0
    def edit(self, id, **kwargs):
        self.editing_id = int(request.args.get("editing_id", 0))
        self.show_fast_add = request.args.get("show_fast_add", False)
        self.ingredient_form = IngredientForm()

        self.form = create_form(RecipeForm, obj=self.recipe)

        self.personal_ingredients = sorted(
            self.recipe.unused_personal_ingredients,
            key=lambda x: unidecode(x.name.lower()),
        )

        self.public_ingredients = sorted(
            self.recipe.unused_public_ingredients,
            key=lambda x: unidecode(x.name.lower()),
        )

        return self.template()
예제 #4
0
    def edit(self):
        self.user_form = create_form(UserForm, obj=self.user)

        return self.template()
예제 #5
0
    def edit(self):
        self.user_form = create_form(UserForm, obj=self.user)
        self.password_form = create_form(PasswordForm)

        return self.template()
예제 #6
0
    def show(self):
        form = create_form(LoginForm)

        return template("auth/login.html.j2", form=form)
예제 #7
0
 def show(self):
     form = create_form(GetNewPasswordForm)
     return template("auth/get_new_password.html.j2", form=form)
예제 #8
0
    def new(self):
        self.form = create_form(IngredientForm)

        return self.template()
예제 #9
0
    def new_shared(self):
        # TODO can be simplified -> redirect? calling super with kwargs?
        form = create_form(IngredientForm)

        return self.template("ingredients/new.html.j2", form=form, shared=True)
예제 #10
0
    def show(self):
        form = create_form(RegisterForm)

        return template("auth/register.html.j2", form=form)
예제 #11
0
    def before_edit(self, id):
        self.form = create_form(IngredientForm, obj=self.ingredient)

        self.recipes = Recipe.load_by_ingredient_and_user(
            self.ingredient, current_user)
        self.all_recipes = Recipe.load_by_ingredient(self.ingredient)
예제 #12
0
 def before_new(self):
     self.form = create_form(IngredientForm)
예제 #13
0
    def edit(self, id):
        self.form = create_form(DietForm, obj=self.diet)

        return self.template()
예제 #14
0
    def new(self):
        self.form = create_form(DietForm)

        return self.template()
예제 #15
0
    def new(self):
        self.form = create_form(RecipeForm)

        return self.template()