Skip to content

Commit

Permalink
fix PDF downloads; fixes #1930
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed Jul 24, 2024
1 parent eda8e52 commit ee7084f
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 ee7084f

Please sign in to comment.