def delete(self, id): """Delete the product GET will return a form asking for approval. POST requests will delete the item. """ c.product = Product.find_by_id(id) return render('/product/confirm_delete.mako')
def _edit(self, id): product = Product.find_by_id(id) for key in self.form_result['product']: setattr(product, key, self.form_result['product'][key]) # update the objects with the validated form data meta.Session.commit() h.flash("The product has been updated successfully.") redirect_to(action='view', id=id)
def _delete(self, id): c.product = Product.find_by_id(id) for include in ProductInclude.find_by_product(id): meta.Session.delete(include) meta.Session.commit() meta.Session.delete(c.product) meta.Session.commit() h.flash("Product has been deleted.") redirect_to('index')
def edit(self, id): c.product = Product.find_by_id(id) defaults = h.object_to_defaults(c.product, 'product') defaults['product.category'] = c.product.category.id defaults['product.ceilings'] = [] for ceiling in c.product.ceilings: defaults['product.ceilings'].append(ceiling.id) form = render('/product/edit.mako') return htmlfill.render(form, defaults)
def edit(self, id): c.product = Product.find_by_id(id) defaults = h.object_to_defaults(c.product, 'product') defaults['product.category'] = c.product.category.id if c.product.fulfilment_type: defaults['product.fulfilment_type'] = c.product.fulfilment_type.id defaults['product.ceilings'] = [] for ceiling in c.product.ceilings: defaults['product.ceilings'].append(ceiling.id) form = render('/product/edit.mako') return htmlfill.render(form, defaults)
def view(self, id): c.can_edit = True c.product = Product.find_by_id(id) return render('/product/view.mako')