コード例 #1
0
ファイル: product.py プロジェクト: PaulWay/zookeepr
    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')
コード例 #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
ファイル: product.py プロジェクト: PaulWay/zookeepr
    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)
コード例 #5
0
ファイル: product.py プロジェクト: PaulWay/zookeepr
    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')
コード例 #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')
コード例 #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)
コード例 #8
0
ファイル: product.py プロジェクト: PaulWay/zookeepr
    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
ファイル: volunteer.py プロジェクト: PaulWay/zookeepr
 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)
コード例 #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)
コード例 #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)
コード例 #12
0
ファイル: product.py プロジェクト: PaulWay/zookeepr
 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')