Skip to content

Commit

Permalink
add use_source_file
Browse files Browse the repository at this point in the history
  • Loading branch information
goose-life committed Sep 11, 2024
1 parent 4776f65 commit 0b722b9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion peachjam/migrations/0156_publicationfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.16 on 2024-09-11 14:00
# Generated by Django 4.2.16 on 2024-09-11 14:44

import django.db.models.deletion
from django.db import migrations, models
Expand Down Expand Up @@ -61,6 +61,14 @@ class Migration(migrations.Migration):
verbose_name="trusted URL",
),
),
(
"use_source_file",
models.BooleanField(
default=False,
help_text="Set to True if the source file on the same document can be used instead",
verbose_name="use source file",
),
),
(
"document",
models.OneToOneField(
Expand Down
7 changes: 7 additions & 0 deletions peachjam/models/core_document_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,13 @@ class PublicationFile(AttachmentAbstractModel):
trusted_url = models.URLField(
_("trusted URL"), max_length=2048, null=True, blank=True
)
use_source_file = models.BooleanField(
_("use source file"),
default=False,
help_text=_(
"Set to True if the source file on the same document can be used instead"
),
)

class Meta:
verbose_name = _("publication file")
Expand Down
7 changes: 7 additions & 0 deletions peachjam/views/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ def render_to_response(self, context, **response_kwargs):
# TODO: review all of this
if hasattr(self.object, "publication_file"):
publication_file = self.object.publication_file
if publication_file.use_source_file:
return redirect(
reverse(
"document_source",
kwargs={"frbr_uri": self.object.expression_frbr_uri[1:]},
)
)
# don't do anything if it's not a PDF
if publication_file.mimetype == "application/pdf":
# if the publication file is remote, just redirect there
Expand Down

0 comments on commit 0b722b9

Please sign in to comment.