mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Added download_url to the Document model
This commit is contained in:
parent
9a437dc9f6
commit
2f0da8ab25
@ -48,7 +48,6 @@ class DocumentAdmin(admin.ModelAdmin):
|
||||
search_fields = ("sender__name", "title", "content")
|
||||
list_display = ("created", "sender", "title", "tags_", "document")
|
||||
list_filter = ("tags", "sender", MonthListFilter)
|
||||
list_editable = ("sender", "title")
|
||||
list_per_page = 25
|
||||
|
||||
def tags_(self, obj):
|
||||
@ -67,11 +66,12 @@ class DocumentAdmin(admin.ModelAdmin):
|
||||
|
||||
def document(self, obj):
|
||||
return '<a href="{}">' \
|
||||
'<img src="{}" width="22" height="22" alt="{} icon">' \
|
||||
'<img src="{}" width="22" height="22" alt="{} icon" title="{}">' \
|
||||
'</a>'.format(
|
||||
reverse("fetch", kwargs={"pk": obj.pk}),
|
||||
obj.download_url,
|
||||
static("documents/img/{}.png".format(obj.file_type)),
|
||||
obj.file_type
|
||||
obj.file_type,
|
||||
obj.file_name
|
||||
)
|
||||
document.allow_tags = True
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import gnupg
|
||||
import os
|
||||
import time
|
||||
|
||||
@ -25,7 +24,6 @@ class Command(Renderable, BaseCommand):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.verbosity = 0
|
||||
self.target = None
|
||||
self.gpg = gnupg.GPG(gnupghome=settings.GNUPG_HOME)
|
||||
BaseCommand.__init__(self, *args, **kwargs)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
@ -44,7 +42,7 @@ class Command(Renderable, BaseCommand):
|
||||
|
||||
for document in Document.objects.all():
|
||||
|
||||
target = os.path.join(self.target, document.parseable_file_name)
|
||||
target = os.path.join(self.target, document.file_name)
|
||||
|
||||
print("Exporting: {}".format(target))
|
||||
|
||||
|
@ -2,6 +2,7 @@ import os
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils import timezone
|
||||
@ -162,7 +163,7 @@ class Document(models.Model):
|
||||
return open(self.source_path, "rb")
|
||||
|
||||
@property
|
||||
def parseable_file_name(self):
|
||||
def file_name(self):
|
||||
if self.sender and self.title:
|
||||
tags = ",".join([t.slug for t in self.tags.all()])
|
||||
if tags:
|
||||
@ -170,3 +171,7 @@ class Document(models.Model):
|
||||
self.sender, self.title, tags, self.file_type)
|
||||
return "{} - {}.{}".format(self.sender, self.title, self.file_type)
|
||||
return os.path.basename(self.source_path)
|
||||
|
||||
@property
|
||||
def download_url(self):
|
||||
return reverse("fetch", kwargs={"pk": self.pk})
|
||||
|
Loading…
x
Reference in New Issue
Block a user