From ee7084fd4ec746865521a1b2aa86e95831bf78a6 Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Wed, 24 Jul 2024 09:07:12 +0200 Subject: [PATCH] fix PDF downloads; fixes #1930 --- peachjam/views/documents.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/peachjam/views/documents.py b/peachjam/views/documents.py index 49d9d3861..a86ef413a 100644 --- a/peachjam/views/documents.py +++ b/peachjam/views/documents.py @@ -116,17 +116,17 @@ def render_to_response(self, context, **response_kwargs): if source_file.source_url and source_file.mimetype == "application/pdf": return redirect(source_file.source_url) - if getattr(source_file.file.storage, "custom_domain", None): - # use the storage's custom domain to serve the file - return redirect(source_file.file.url) - pdf = source_file.as_pdf() if pdf: - return self.make_response( - pdf, - "application/pdf", - source_file.filename_for_download(".pdf"), - ) + if getattr(pdf.storage, "custom_domain", None): + # use the storage's custom domain to serve the file + return redirect(pdf.url) + else: + return self.make_response( + pdf, + "application/pdf", + source_file.filename_for_download(".pdf"), + ) raise Http404()