Exemple #1
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')
Exemple #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)
Exemple #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')
Exemple #4
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)
Exemple #5
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')
Exemple #6
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')
Exemple #7
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)
Exemple #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)
Exemple #9
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)
Exemple #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.integer_to_currency(p.cost)])
     form = render('volunteer/accept.mako') 
     return htmlfill.render(form, defaults)
Exemple #11
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
        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)
Exemple #12
0
 def view(self, id):
     c.can_edit = True
     c.product = Product.find_by_id(id)
     return render('/product/view.mako')
Exemple #13
0
 def view(self, id):
     c.can_edit = True
     c.product = Product.find_by_id(id)
     return render('/product/view.mako')