def edit(self, id): recipe = Recipe.get_by_id(id) if not recipe: abort(404) c.update_url = url.current(action='update', id=id) html = render('/recipe_edit.mako') return htmlfill.render(html, model_dict(recipe))
def delete(self, id): recipe = Recipe.get_by_id(id) if not recipe: abort(404) # Not found self._own_recipe(recipe) title = recipe.title recipe.delete() redirect(url.current(action='mine', message='Recipe "%s" deleted.' % title))
def update(self, id): recipe = Recipe.get_by_id(id) if not recipe: abort(404) # Not found self._own_recipe(recipe) for k, v in self.form_result.iteritems(): setattr(recipe, k, v) recipe.put() redirect(url.current(action='view', id=id, message="Recipe updated."))
def view(self, id=None): c.message = request.params.get('message', None) if not id: abort(404) c.recipe = Recipe.get_by_id(id) if not c.recipe: abort(404) c.rm_url = url(controller='recipe', action='delete', id=id) c.edit_url = url(controller='recipe', action='edit', id=id) c.list_url = url(controller='recipe', action='browse') c.add_url = url(controller='recipe', action='add') return render('/recipe_view.mako')