def __call__(self):
        settings = get_settings()
        self.organization_name = settings.organization_name
        self.campaign = self.context.get_fundraising_campaign()
        self.page = self.context.get_fundraising_campaign_page()
        self.donation_receipt_legal = self.campaign.donation_receipt_legal

        self.products = []
        if self.context.products:
            for product in self.context.products:
                price, quantity, product_uuid = product.split('|', 2)
                total = int(price) * int(quantity)
                product = uuidToObject(product_uuid)
                if not product:
                    continue
                if product.donation_only:
                    price = total
                    quantity = '-'
                self.products.append({
                    'price': price,
                    'quantity': quantity,
                    'product': product,
                    'total': total,
                })

        self.is_personal = self.page.is_personal()

        module = os.sys.modules[martian.util.caller_module()]
        _prefix = os.path.dirname(module.__file__)

        pt = PageTemplateFile('donation_templates/receipt.pt')
        return pt.pt_render({'view': self})
Example #2
0
def render_javascript(charts, packages):
    """Render the javascript for the charts and packages"""
    render_charts = []
    for chart in charts:
        if 'charttype' in chart and 'data' in chart:
            render_charts.append(chart)
    if len(render_charts) == 0:
        return None
    pagetemplate = PageTemplateFile('templates/javascript.pt')
    context = {'packages': "'%s'" % ','.join(packages),
               'charts': render_charts}
    return pagetemplate.pt_render(namespace=context)
Example #3
0
def render_javascript(charts, packages):
    """Render the javascript for the charts and packages"""
    render_charts = []
    for chart in charts:
        if 'charttype' in chart and 'data' in chart:
            render_charts.append(chart)
    if len(render_charts) == 0:
        return None
    pagetemplate = PageTemplateFile('templates/javascript.pt')
    context = {
        'packages': "'%s'" % ','.join(packages),
        'charts': render_charts
    }
    return pagetemplate.pt_render(namespace=context)
Example #4
0
def render(path, options):
    tpl = PageTemplateFile(path, globals())
    ns = tpl.pt_getContext((), options)
    return tpl.pt_render(ns)
Example #5
0
 def get(self):
   my_pt = PageTemplateFile('main.pt') 
   context = {'rows': ['apple', 'banana', 'carrot'], 'foo':'bar'}
   self.response.out.write(my_pt.pt_render(namespace=context))
def render(path, options):
    tpl = PageTemplateFile(path, globals())
    ns = tpl.pt_getContext((), options)
    return tpl.pt_render(ns)