Пример #1
0
    def _delete(self, id):
        c.product = Product.find_by_id(id)
        meta.Session.delete(c.product)
        meta.Session.commit()

        h.flash("Product has been deleted.")
        redirect_to('index')
Пример #2
0
    def _new(self):
        results = self.form_result['product']

        c.product = Product(**results)
        meta.Session.add(c.product)
        meta.Session.commit()

        h.flash("Product created")
        redirect_to(action='view', id=c.product.id)
Пример #3
0
    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')
Пример #4
0
    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')
Пример #5
0
    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)
Пример #6
0
    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)
Пример #7
0
    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')
Пример #8
0
    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)
Пример #9
0
    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)
Пример #10
0
 def accept(self, id):
     volunteer = Volunteer.find_by_id(id)
     category = ProductCategory.find_by_name("Ticket")
     products = Product.find_by_category(category.id)
     defaults = {}
     if volunteer.ticket_type:
         defaults["ticket_type"] = volunteer.ticket_type.id
     c.products_select = []
     c.products_select.append(["", "No Ticket"])
     for p in products:
         if "Volunteer" in p.description:
             c.products_select.append([p.id, p.description + " - " + h.number_to_currency(p.cost / 100)])
     form = render("volunteer/accept.mako")
     return htmlfill.render(form, defaults)
Пример #11
0
 def accept(self, id):
     volunteer = Volunteer.find_by_id(id)
     category = ProductCategory.find_by_name('Ticket')
     products = Product.find_by_category(category.id)
     defaults = {}
     if volunteer.ticket_type:
         defaults['ticket_type'] = volunteer.ticket_type.id
     c.products_select = []
     c.products_select.append(['', 'No Ticket'])
     for p in products:
         if 'Volunteer' in p.description:
             c.products_select.append([
                 p.id,
                 p.description + ' - ' + h.number_to_currency(p.cost / 100)
             ])
     form = render('volunteer/accept.mako')
     return htmlfill.render(form, defaults)
Пример #12
0
 def view(self, id):
     c.can_edit = True
     c.product = Product.find_by_id(id)
     return render('/product/view.mako')
Пример #13
0
 def view(self, id):
     c.can_edit = True
     c.product = Product.find_by_id(id)
     return render('/product/view.mako')