Пример #1
0
def view(request, slug, template_name='dbr/view.html'):
    '''
    Renders the main report's view
    '''
    report_id = Report.objects.get(slug=slug).id
    ireport, messages_list = ireport_factory(slug)
    for m in messages_list:
        messages.add_message(request, *m)
    context = {
        'report' : ireport,
        'report_id' : report_id,
        'report_slug' : slug,
    }
    return render_to_response(
        template_name,
        context,
        context_instance = RequestContext(request)
    )
Пример #2
0
def export(request, slug, fmt):
    '''
    Exports a **report** to any of the supported formats.
    Currently supported formats are:
    - html
    - xml (Docutils dialect)
    - pdf
    - txt
    - rst
    - odt
    - csv
    '''
    ireport = ireport_factory(slug)

    mime = fmt in MIMES and MIMES[fmt] or None

    response = HttpResponse(document(ireport, fmt), mimetype=mime)
    response['Cache-Control'] = 'no-cache'
    if fmt in ('pdf', 'odt', 'csv'):
        response['Content-Disposition'] = 'attachment; filename=report.%s' % fmt

    return response