def post(self): login.logging_user(self) title_last = self.request.get("rtitle") ingr_last = self.request.get("ringredientes") prep_last = self.request.get("rpreparacion") if title_last != "" and ingr_last != "" and prep_last != "": currentUser = users.get_current_user().nickname() aux = Recipe(parent=ndb.Key("Recipe", title_last or "*notitle*"), title=title_last, ingredients=ingr_last, directions=prep_last, author=currentUser) aux.put() time.sleep(0.5) recetas = Recipe.query() template_values = {'recetas': recetas} jinja = jinja2.get_jinja2(app=self.app) self.response.write( jinja.render_template("index.html", **template_values))
def get(self): login.logging_user(self) recetas = Recipe.query() template_values = {'recetas': recetas} jinja = jinja2.get_jinja2(app=self.app) self.response.write( jinja.render_template("index.html", **template_values))
def get(self): login.logging_user(self) recetas = Recipe.query() recipe_id = self.request.get("id") receta_actual = None for receta in recetas: if str(receta.key.id()) == recipe_id: receta_actual = receta comentarios = Comment.query(Comment.recipe_id == str(recipe_id)) template_values = { 'receta_actual': receta_actual, 'comentarios': comentarios } jinja = jinja2.get_jinja2(app=self.app) self.response.write( jinja.render_template("recipeView.html", **template_values))
def post(self): login.logging_user(self) recetas = Recipe.query() recipe_id = self.request.get("id") comments_author = self.request.get("author") comments_content = self.request.get("content") comments_title = self.request.get("title-commment") if comments_author != "" and comments_content != "" and recipe_id != "" and comments_title != "": comentario = Comment(author=comments_author, comment=comments_content, recipe_id=recipe_id, title=comments_title) comentario.put() time.sleep(0.5) comentarios = Comment.query(Comment.recipe_id == str(recipe_id)) receta_actual = None for receta in recetas: if str(receta.key.id()) == recipe_id: receta_actual = receta template_values = { 'receta_actual': receta_actual, 'comentarios': comentarios } jinja = jinja2.get_jinja2(app=self.app) self.response.write( jinja.render_template("recipeView.html", **template_values))