Exemplo n.º 1
0
    def index(self):
        shared_ingredients = Ingredient.load_all_shared(renamed=True)

        if current_user.is_authenticated:
            users_ingredients = Ingredient.load_all_by_author(current_user.username)
            self.ingredients = users_ingredients + shared_ingredients
            self.diets = current_user.active_diets
        else:
            self.ingredients = shared_ingredients
            self.diets = None

        return self.template()
Exemplo n.º 2
0
    def new(self):
        from app.helpers.general import list_without_duplicated

        active_diets = current_user.active_diets
        user_ingredients = Ingredient.load_all_by_author(current_user.username)
        shared_ingredients = Ingredient.load_all_shared(renamed=True)

        ingredients = user_ingredients + shared_ingredients
        self.ingredients = list_without_duplicated(ingredients)

        self.preset_ingredients = request.args.get("preset_ingredient_ids", [])
        self.diets = active_diets
        self.is_trialrecipe = False

        return self.template()
Exemplo n.º 3
0
 def before_all_shared(self):
     self.shared_ingredients = Ingredient.load_all_shared()
     self.unapproved_ingredients = Ingredient.load_all_unapproved()
Exemplo n.º 4
0
 def before_index(self):
     self.ingredients = Ingredient.load_all_by_author(current_user)
     self.shared_ingredients = Ingredient.load_all_shared()