The first stages of getting thumbnails back

This commit is contained in:
Daniel Quinn
2016-03-05 01:57:49 +00:00
parent 5c41e717f0
commit 52f15b4de1
7 changed files with 135 additions and 5 deletions

View File

@@ -171,6 +171,7 @@ class Document(models.Model):
return os.path.join(
settings.MEDIA_ROOT,
"documents",
"originals",
"{:07}.{}.gpg".format(self.pk, self.file_type)
)
@@ -184,7 +185,24 @@ class Document(models.Model):
@property
def download_url(self):
return reverse("fetch", kwargs={"pk": self.pk})
return reverse("fetch", kwargs={"kind": "doc", "pk": self.pk})
@property
def thumbnail_path(self):
return os.path.join(
settings.MEDIA_ROOT,
"documents",
"thumbnails",
"{:07}.jpg.gpg".format(self.pk)
)
@property
def thumbnail_file(self):
return open(self.thumbnail_path, "rb")
@property
def thumbnail_url(self):
return reverse("fetch", kwargs={"kind": "thumb", "pk": self.pk})
class Log(models.Model):