From a6f0a53702a940bf055dadb3bf558aea49c6d862 Mon Sep 17 00:00:00 2001 From: Simon Law Date: Tue, 24 Jul 2012 16:29:30 -0400 Subject: Cleanups and documentation. --- wkhtmltopdf/views.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py index bd1da13..c337b6c 100644 --- a/wkhtmltopdf/views.py +++ b/wkhtmltopdf/views.py @@ -1,6 +1,5 @@ from __future__ import absolute_import -import os from re import compile from tempfile import NamedTemporaryFile import warnings @@ -8,7 +7,6 @@ import warnings from django.conf import settings from django.contrib.sites.models import Site from django.http import HttpResponse -from django.template.context import RequestContext from django.template.response import TemplateResponse from django.views.generic import TemplateView @@ -16,6 +14,8 @@ from .utils import (content_disposition_filename, wkhtmltopdf) class PDFResponse(HttpResponse): + """HttpResponse that sets the headers for PDF output.""" + def __init__(self, content, mimetype=None, status=200, content_type=None, filename=None, *args, **kwargs): @@ -134,10 +134,17 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse): class PDFTemplateView(TemplateView): + """Class-based view for HTML templates rendered to PDF.""" + + # Filename for downloaded PDF. If None, the response is inline. filename = 'rendered_pdf.pdf' - footer_template = None + + # Filenames for the content, header, and footer templates. + template_name = None header_template = None + footer_template = None + # TemplateResponse classes for PDF and HTML response_class = PDFTemplateResponse html_response_class = TemplateResponse -- cgit v1.2.3