Skip to content

Commit

Permalink
keep it simple: subclass AttachmentAbstractModel
Browse files Browse the repository at this point in the history
  • Loading branch information
goose-life committed Sep 10, 2024
1 parent 4695fcc commit 66bc841
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions peachjam/models/core_document_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def save(self, *args, **kwargs):
self.set_download_filename()


class PublicationFile(SourceFile):
class PublicationFile(AttachmentAbstractModel):
SAVE_FOLDER = "publication_file"

document = models.OneToOneField(
Expand All @@ -905,6 +905,9 @@ class PublicationFile(SourceFile):
on_delete=models.CASCADE,
verbose_name=_("document"),
)
source_url = models.URLField(
_("source URL"), max_length=2048, null=True, blank=True
)
trusted_url = models.URLField(
_("trusted URL"), max_length=2048, null=True, blank=True
)
Expand All @@ -913,24 +916,6 @@ class Meta:
verbose_name = _("publication file")
verbose_name_plural = _("publication files")

def as_pdf(self):
# assume the publication file is a PDF; if not, ignore it
if self.mimetype == "application/pdf":
return self.file
return None

def convert_to_pdf(self):
# don't convert anything
pass

def ensure_file_as_pdf(self):
# don't convert anything
pass

def filename_for_download(self, ext=None):
filename = super().filename_for_download(ext=ext)
return "Publication file: " + filename


class AttachedFileNature(models.Model):
name = models.CharField(
Expand Down

0 comments on commit 66bc841

Please sign in to comment.