Add compensation form PDF for EDS section
This commit is contained in:
parent
bfb5609c9a
commit
e0cd5db7fb
7 changed files with 212 additions and 88 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import io
|
||||
import os
|
||||
import tempfile
|
||||
import zipfile
|
||||
|
||||
from django.contrib import messages
|
||||
from django.core.mail import EmailMessage
|
||||
from django.http import HttpResponse
|
||||
from django.http import FileResponse, HttpResponse
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import FormView, View
|
||||
|
||||
|
|
@ -51,6 +52,18 @@ class EmailConfirmationBaseView(FormView):
|
|||
return context
|
||||
|
||||
|
||||
class PDFBaseView(View):
|
||||
pdf_class = None
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
buff = io.BytesIO()
|
||||
pdf = self.pdf_class(buff, obj)
|
||||
pdf.produce()
|
||||
buff.seek(0)
|
||||
return FileResponse(buff, as_attachment=True, filename=self.filename(obj))
|
||||
|
||||
|
||||
class ZippedFilesBaseView(View):
|
||||
"""A base class to return a .zip file containing a compressed list of files."""
|
||||
filename = 'to_be_defined.zip'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue