Example #1
0
 def get(self):
     recipe_query = Recipe.all()
     recipes = recipe_query.run()
         
     template_values = {
         'recipes': recipes,
         'location_provider': RecipeLocationProvider(),
     }
     
     self.render_template('recipes.html', template_values)
Example #2
0
 def get_recipe(self,request):
     recipe_query = Recipe.all().filter('user_id =', request.user_id)
     recipes_model = recipe_query.run()
     recipes_response = []
     for recipe_model in recipes_model:
         recipe_message = RecipeMessage(title=recipe_model.title,
                                        author=recipe_model.author,
                                        cookbook=recipe_model.cookbook,
                                        photo_url=recipe_model.photo_url)
         if request.include_ingredients and request.include_ingredients.lower() == 'true':
             ingredients_message = []
             ingredients_model = recipe_model.items.run()
             for ingredient_model in ingredients_model:
                 ingredients_message.append(IngredientMessage(ingredient=ingredient_model.ingredient,
                                                             quantity=ingredient_model.quantity,
                                                             unit=ingredient_model.unit))
             recipe_message.ingredients = ingredients_message
         recipes_response.append(recipe_message)
 
     return GetRecipesResponse(recipes=recipes_response)