Example #1
0
    def __before__(self, **kwargs):
        category = ProductCategory.find_by_name('Accommodation')
        if category and not (len(category.products) == 0 or (len(category.products) == 1 and category.products[0].cost == 0)):
            allowed_categories.append('Accommodation')


        c.product_categories = ProductCategory.find_all()
        self._generate_product_schema()
Example #2
0
    def product_list(self):
        print ProductCategory.find_all()
        print ProductCategory.find_all()[0].products
        print ProductCategory.find_all()[0].products[0]
        print ProductCategory.find_all()[0].products[0].__dict__

        raw = []
        for r in ProductCategory.find_all():
            products = [{
                "id": p.id,
                "active": p.active,
                "description": p.description,
                "cost": p.cost
            } for p in r.products]
            raw.append({
                "id": r.id,
                "name": r.name,
                "description": r.description,
                "note": r.note,
                "display_order": r.display_order,
                "display": r.display,
                "display_mode": r.display_mode,
                "invoice_free_products": r.invoice_free_products,
                "min_qty": r.min_qty,
                "max_qty": r.max_qty,
                "products": products
            })
        return raw
Example #3
0
    def refund(self, id):
        invoice = Invoice.find_by_id(id)
        try:
            c.invoice_person = invoice.person.id
        except:
            c.invoice_person = ''

        c.due_date = datetime.date.today().strftime("%d/%m/%Y")

        c.product_categories = ProductCategory.find_all()
        # The form adds one to the count by default, so we need to decrement it
        c.item_count = len(invoice.items) - 1

        defaults = dict()
        defaults['invoice.person' ] = c.invoice_person
        defaults['invoice.due_date'] = c.due_date
        for i in range(len(invoice.items)):
            item = invoice.items[i]
            if item.product:
                defaults['invoice.items-' + str(i) + '.product'] = item.product.id
            else:
                defaults['invoice.items-' + str(i) + '.description'] = item.description
            defaults['invoice.items-' + str(i) + '.qty'] = -item.qty
            defaults['invoice.items-' + str(i) + '.cost'] = item.cost
        form = render("/invoice/new.mako")
        return htmlfill.render(form, defaults, use_all_keys=True)
Example #4
0
    def refund(self, id):
        invoice = Invoice.find_by_id(id)
        try:
            c.invoice_person = invoice.person.id
        except:
            c.invoice_person = ''

        c.due_date = datetime.date.today().strftime("%d/%m/%Y")

        c.product_categories = ProductCategory.find_all()
        # The form adds one to the count by default, so we need to decrement it
        c.item_count = len(invoice.items) - 1

        defaults = dict()
        defaults['invoice.person'] = c.invoice_person
        defaults['invoice.due_date'] = c.due_date
        for i in range(len(invoice.items)):
            item = invoice.items[i]
            if item.product:
                defaults['invoice.items-' + str(i) +
                         '.product'] = item.product.id
            else:
                defaults['invoice.items-' + str(i) +
                         '.description'] = item.description
            defaults['invoice.items-' + str(i) + '.qty'] = -item.qty
            defaults['invoice.items-' + str(i) + '.cost'] = item.cost
        form = render("/invoice/new.mako")
        return htmlfill.render(form, defaults, use_all_keys=True)
Example #5
0
    def new(self):
        try:
            c.invoice_person = request.GET['person_id']
        except:
            c.invoice_person = ''

        c.due_date = datetime.date.today().strftime("%d/%m/%Y")

        c.product_categories = ProductCategory.find_all()
        c.item_count = 0;
        return render("/invoice/new.mako")
Example #6
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)
Example #7
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)
Example #8
0
    def product_list(self):
        print ProductCategory.find_all()
        print ProductCategory.find_all()[0].products
        print ProductCategory.find_all()[0].products[0]
        print ProductCategory.find_all()[0].products[0].__dict__

        raw = []
        for r in ProductCategory.find_all():
            products = [{"id":p.id, "active":p.active, "description":p.description, "cost":p.cost} for p in r.products]
            raw.append({
                "id": r.id,
                "name":r.name,
                "description":r.description,
                "note":r.note,
                "display_order":r.display_order,
                "display":r.display,
                "display_mode":r.display_mode,
                "invoice_free_products":r.invoice_free_products,
                "min_qty":r.min_qty,
                "max_qty":r.max_qty,
                "products":products
            })
        return raw
Example #9
0
 def _to_python(self, value, state):
     return ProductCategory.find_by_id(value)
Example #10
0
 def __before__(self, **kwargs):
     c.product_categories = ProductCategory.find_nonfree()
     self._generate_product_schema()
Example #11
0
 def new(self):
     c.product_categories = ProductCategory.find_all()
     return render("/invoice/new.mako")
Example #12
0
 def __before__(self, **kwargs):
     c.product_categories = ProductCategory.find_nonfree()
     self._generate_product_schema()
Example #13
0
 def new(self):
     c.product_categories = ProductCategory.find_all()
     return render("/invoice/new.mako")
Example #14
0
 def _to_python(self, value, state):
     return ProductCategory.find_by_id(value)