Exemple #1
0
 def get(cls, id: str):
     data = {}
     user = UserModel.find_by_id(get_jwt_identity())
     hop = HopsModel.find_by_id(id)
     all_recipes = RecipeModel.query.filter(RecipeModel.hops.any(
         RecipeHops.hop_id == id)).filter(RecipeModel.published == True).filter(RecipeModel.private_recipe == False)
     data["all_recipes"] = recipes_schema.dump(all_recipes)
     data["hop"] = hop_schema.dump(hop)
     if user:
         your_recipes = RecipeModel.query.filter(RecipeModel.hops.any(
             RecipeHops.hop_id == id)).filter(RecipeModel.user_id == user.id)
         data["your_recipes"] = recipes_schema.dump(your_recipes)
     return data, 200
Exemple #2
0
 def get(cls, id: str):
     data = {}
     user = UserModel.find_by_id(get_jwt_identity())
     yeast = YeastModel.find_by_id(id)
     all_recipes = RecipeModel.query.filter(
         RecipeModel.yeasts.any(RecipeYeasts.yeast_id == id)).filter(
             RecipeModel.published == True).filter(
                 RecipeModel.private_recipe == False)
     data["all_recipes"] = recipes_schema.dump(all_recipes)
     data["yeast"] = yeast_schema.dump(yeast)
     if user:
         your_recipes = RecipeModel.query.filter(
             RecipeModel.yeasts.any(RecipeYeasts.yeast_id == id)).filter(
                 RecipeModel.user_id == user.id)
         data["your_recipes"] = recipes_schema.dump(your_recipes)
     return data, 200
Exemple #3
0
 def get(cls, page):
     user_id = get_jwt_identity()
     recipes = RecipeModel.query.filter_by(
         user_id=user_id).paginate(page=page, per_page=20)
     if recipes.items:
         return recipes_schema.dump(recipes.items)
     return {"message": "No Recipes Created Yet! Get started homebrewing with the Add Recipe button."}, 404
Exemple #4
0
 def get(cls, id: str):
     data = {}
     user = UserModel.find_by_id(get_jwt_identity())
     fermentable = FermentablesModel.find_by_id(id)
     all_recipes = RecipeModel.query.filter(
         RecipeModel.fermentables.any(
             RecipeFermentables.fermentable_id == id)).filter(
                 RecipeModel.published == True).filter(
                     RecipeModel.private_recipe == False)
     data["all_recipes"] = recipes_schema.dump(all_recipes)
     data["fermentable"] = fermentable_schema.dump(fermentable)
     if user:
         your_recipes = RecipeModel.query.filter(
             RecipeModel.fermentables.any(
                 RecipeFermentables.fermentable_id == id)).filter(
                     RecipeModel.user_id == user.id)
         data["your_recipes"] = recipes_schema.dump(your_recipes)
     return data, 200
Exemple #5
0
 def get(cls):
     q = request.args['q']
     query, total = RecipeModel.search(q, 1, 5)
     return recipes_schema.dump(query.all())
Exemple #6
0
 def get(cls, page):
     recipes = RecipeModel.query.paginate(page=page, per_page=2)
     if recipes.items:
         return recipes_schema.dump(recipes.items)
     return {"message": NO_RECIPES_FOUND}, 404