Fixed a few consumer bugs and added an exporter

Rename exporter to export and fixt some debugging

Account for files not matching the sender/title pattern

Added a safety note

Wrong regex on the name parser

Renamed the command to something slightly less ambiguous
This commit is contained in:
Daniel Quinn
2016-01-14 19:47:57 +00:00
parent 2e48036f92
commit 17615d43cb
9 changed files with 141 additions and 24 deletions

View File

@@ -1,10 +1,9 @@
import gnupg
from django.conf import settings
from django.http import HttpResponse
from django.template.defaultfilters import slugify
from django.views.generic.detail import DetailView
from paperless.db import GnuPG
from .models import Document
@@ -17,12 +16,8 @@ class PdfView(DetailView):
Override the default to return the unencrypted PDF as raw data.
"""
gpg = gnupg.GPG(gnupghome=settings.GNUPG_HOME)
response = HttpResponse(gpg.decrypt_file(
self.object.pdf,
passphrase=settings.PASSPHRASE,
).data, content_type="application/pdf")
response = HttpResponse(
GnuPG.decrypted(self.object.pdf), content_type="application/pdf")
response["Content-Disposition"] = 'attachment; filename="{}"'.format(
slugify(str(self.object)) + ".pdf")