paperless-ngx/src/documents/views.py
Daniel Quinn 17615d43cb 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
2016-01-15 18:14:42 +00:00

24 lines
674 B
Python

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
class PdfView(DetailView):
model = Document
def render_to_response(self, context, **response_kwargs):
"""
Override the default to return the unencrypted PDF as raw data.
"""
response = HttpResponse(
GnuPG.decrypted(self.object.pdf), content_type="application/pdf")
response["Content-Disposition"] = 'attachment; filename="{}"'.format(
slugify(str(self.object)) + ".pdf")
return response