예제 #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)
예제 #2
0
 def get(self, recipe_key):
     recipe = Recipe.get(recipe_key)
     
     location_provider = RecipeLocationProvider()
     
     template_values = {
         'recipe': recipe,
         'location_provider': location_provider
     }
     
     self.render_template('recipe.html', template_values)
예제 #3
0
 def post(self):
     recipe = Recipe()
     
     recipe.title = self.request.get("title")
     recipe.author = self.request.get("author")
     recipe.cookbook = self.request.get("cookbook")
     recipe.set_photo(self.request.get("img"))
     
     ingredients = self.request.get_all("ingredient")
     
     recipe.put()
     
     for ingredient in ingredients:
         RecipeItem(recipe=recipe, ingredient=ingredient).put()
     
     template_values = {
         "recipe": recipe,
         "location_provider": RecipeLocationProvider()
     }
     self.render_template("float_element.html", template_values)
예제 #4
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)
예제 #5
0
 def get(self):
     recipe = Recipe.get(self.request.get('img_id'))
     self.set_img_response(recipe.icon)
예제 #6
0
 def post(self, recipe_key):
     recipe = Recipe.get(recipe_key)
     recipe.delete()
     
     redirect = Redirect(RecipesHandler.location())
     self.set_json_response(json.dumps(redirect.__dict__))