aboutsummaryrefslogtreecommitdiffstats
path: root/wkhtmltopdf/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'wkhtmltopdf/views.py')
-rw-r--r--wkhtmltopdf/views.py45
1 files changed, 3 insertions, 42 deletions
diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py
index 741742f..210ff0a 100644
--- a/wkhtmltopdf/views.py
+++ b/wkhtmltopdf/views.py
@@ -1,8 +1,7 @@
from __future__ import absolute_import
-from re import compile
from tempfile import NamedTemporaryFile
-import warnings
+import re
from django.conf import settings
from django.http import HttpResponse
@@ -39,13 +38,6 @@ class PDFResponse(HttpResponse):
del self['Content-Disposition']
-class PdfResponse(PDFResponse):
- def __init__(self, content, filename):
- warnings.warn('PdfResponse is deprecated in favour of PDFResponse. It will be removed in version 1.',
- PendingDeprecationWarning, 2)
- super(PdfResponse, self).__init__(content, filename=filename)
-
-
class PDFTemplateResponse(TemplateResponse, PDFResponse):
"""Renders a Template into a PDF using wkhtmltopdf"""
@@ -75,7 +67,7 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse):
self.override_settings = override_settings
def render_to_temporary_file(self, template_name, mode='w+b', bufsize=-1,
- suffix='', prefix='tmp', dir=None,
+ suffix='.html', prefix='tmp', dir=None,
delete=True):
template = self.resolve_template(template_name)
@@ -169,7 +161,7 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse):
if self.override_settings is not None:
overrides.update(self.override_settings)
- has_scheme = compile(r'^[^:/]+://')
+ has_scheme = re.compile(r'^[^:/]+://')
# If MEDIA_URL doesn't have a scheme, we transform it into a
# file:// URL based on MEDIA_ROOT.
@@ -230,11 +222,6 @@ class PDFTemplateView(TemplateView):
def get_cmd_options(self):
return self.cmd_options
- def get_pdf_kwargs(self):
- warnings.warn('PDFTemplateView.get_pdf_kwargs() is deprecated in favour of get_cmd_options(). It will be removed in version 1.',
- PendingDeprecationWarning, 2)
- return self.get_cmd_options()
-
def render_to_response(self, context, **response_kwargs):
"""
Returns a PDF response with a template rendered with the given context.
@@ -262,29 +249,3 @@ class PDFTemplateView(TemplateView):
context=context,
**response_kwargs
)
-
-
-class PdfTemplateView(PDFTemplateView): #TODO: Remove this in v1.0
- orientation = 'portrait'
- margin_bottom = 0
- margin_left = 0
- margin_right = 0
- margin_top = 0
-
- def __init__(self, *args, **kwargs):
- warnings.warn('PdfTemplateView is deprecated in favour of PDFTemplateView. It will be removed in version 1.',
- PendingDeprecationWarning, 2)
- super(PdfTemplateView, self).__init__(*args, **kwargs)
-
- def get_cmd_options(self):
- return self.get_pdf_kwargs()
-
- def get_pdf_kwargs(self):
- kwargs = {
- 'margin_bottom': self.margin_bottom,
- 'margin_left': self.margin_left,
- 'margin_right': self.margin_right,
- 'margin_top': self.margin_top,
- 'orientation': self.orientation,
- }
- return kwargs