Skip to content

Commit

Permalink
Merge pull request #1931 from laws-africa/pdf-download
Browse files Browse the repository at this point in the history
fix PDF downloads
  • Loading branch information
longhotsummer authored Jul 24, 2024
2 parents f23f19b + ee7084f commit c32cd1a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions peachjam/views/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down

0 comments on commit c32cd1a

Please sign in to comment.