How to use the relatorio.templates.opendocument.Template function in relatorio

To help you get started, we’ve selected a few relatorio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github machinalis / eff / eff_site / eff / views.py View on Github external
@login_required
@user_passes_test(__enough_perms, login_url='/accounts/login/')
def eff_client_report(request, client_slug):

    client = get_object_or_404(Client, slug=client_slug)
    context = __process_dates(request)
    from_date = context['from_date']
    to_date = context['to_date']

    if 'export' in request.GET:
        if request.GET['export'] == 'odt':
            if 'detailed' in request.GET:
                basic = Template(source=None, filepath=os.path.join(cur_dir,
                    '../templates/reporte_cliente_detallado.odt'))
                report_by_project = dict(map(lambda x: x[0], client.report(
                    from_date, to_date, True)))
                report_data = format_report_data(report_by_project, client,
                    from_date, to_date, True)
                report_data['clientname'] = client.name
                basic_generated = basic.generate(o=report_data).render()
                resp = HttpResponse(basic_generated.getvalue(),
                    mimetype='application/vnd.oasis.opendocument.text')
                cd = 'filename=billing-%s-%s-logs.odt' % (from_date.year,
                    from_date.strftime("%m"), )
                resp['Content-Disposition'] = cd
                return resp
            else:
                basic = Template(source=None, filepath=os.path.join(cur_dir,
                    '../templates/reporte_cliente.odt'))
github hugsy / stuff / unmap.py View on Github external
def export(self):
        tab = self.sort_data()

        try :
            relatorio =  sys.modules['relatorio']
            template = relatorio.templates.opendocument.Template(source=None, filepath=self.template)
            data = template.generate(o=tab).render().getvalue()

            if len(tab['lines']) > 0:
                with open(self.filename,'w') as fd:
                    fd.write(data)
                    if self.verbose:
                        self.logger.info ("MD5: %s" % md5(data).hexdigest())

        except Exception, e:
            self.logger.error("export failed : %s" % e)
github machinalis / eff / eff_site / eff / views.py View on Github external
'city': client.city or '',
                           'state_and_country': state_and_country,
                           'currency': client.currency.ccy_symbol or \
                               client.currency.ccy_code,
                           }
            today = datetime.now()
            reverse_billing = FixedPriceClientReverseBilling(
                project_data={'name': project.name,
                              'price': str(project.fixed_price)},
                client_data=client_data,
                today=today.strftime("%A, %d %B %Y"),
                reference="%s%s%s" % (client.name.lower(), today.year,
                    today.strftime("%m"))
                )

            basic = Template(source=None, filepath=os.path.join(cur_dir,
                '../templates/reporte_cliente_precio_fijo.odt'))
            basic_generated = basic.generate(o=reverse_billing).render()
            resp = HttpResponse(basic_generated.getvalue(),
                mimetype='application/vnd.oasis.opendocument.text')
            cd = 'filename=billing-%s.odt' % project.external_id
            resp['Content-Disposition'] = cd
            return resp

        return render_to_response('admin_reportes_cliente_costo_fijo.html',
            context)
    else:
        client_id = request.POST['client']
        client = get_object_or_404(Client, id=client_id)
        projects = Project.objects.filter(client=client, billing_type='FIXED')
        ret = '<option value="" selected="selected">----</option>'
        ret += ''.join(['<option value="%s">%s</option>' % (p.id, p.name) \
github machinalis / eff / eff_site / eff / views.py View on Github external
from_date = context['from_date']
    to_date = context['to_date']
    user = User.objects.get(username=user_name)

    project = None
    if 'project' in request.GET:
        project = request.GET['project']
        context['project'] = project

    # detailed log report
    context['report'] = user.get_profile().report(from_date, to_date, project)

    if 'export' in request.GET:
        if request.GET['export'] == 'odt':
            if 'detailed' in request.GET:
                basic = Template(source=None, filepath=os.path.join(cur_dir,
                    '../templates/reporte_usuario_detallado.odt'))
                report_data = format_report_data_user(context['report'], user,
                    from_date, to_date, True)
                basic_generated = basic.generate(o=report_data).render()
                resp = HttpResponse(basic_generated.getvalue(),
                    mimetype='application/vnd.oasis.opendocument.text')
                cd = 'filename=reverse_billing-%s-%s-logs.odt' % (
                    from_date.year, from_date.strftime("%m"), )
                resp['Content-Disposition'] = cd
                return resp
            else:
                basic = Template(source=None, filepath=os.path.join(cur_dir,
                    '../templates/reporte_usuario.odt'))
                report_by_project = list(TimeLog.get_summary_per_project(
                    user.get_profile(), from_date, to_date, True))
                report_by_project.sort(cmp=lambda (x0, x1, x2, x3, x4),

relatorio

A templating library able to output odt and pdf files

GPL-3.0
Latest version published 5 days ago

Package Health Score

67 / 100
Full package analysis

Similar packages