mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-11 09:07:18 +01:00
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
24 lines
674 B
Python
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
|