mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Directly serve invoice PDFs via Django
This commit is contained in:
@@ -4,7 +4,7 @@ from itertools import groupby
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.http import Http404, HttpResponseNotAllowed
|
from django.http import FileResponse, Http404, HttpResponseNotAllowed
|
||||||
from django.shortcuts import redirect, render
|
from django.shortcuts import redirect, render
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
@@ -381,7 +381,9 @@ class InvoiceDownload(EventPermissionRequiredMixin, View):
|
|||||||
'now. Please try again in a few seconds.'))
|
'now. Please try again in a few seconds.'))
|
||||||
return redirect(self.get_order_url())
|
return redirect(self.get_order_url())
|
||||||
|
|
||||||
return redirect(self.invoice.file.url)
|
resp = FileResponse(self.invoice.file.file, content_type='application/pdf')
|
||||||
|
resp['Content-Disposition'] = 'attachment; filename="{}.pdf"'.format(self.invoice.number)
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
class OrderDownload(OrderView):
|
class OrderDownload(OrderView):
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from django.contrib import messages
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from django.http import Http404
|
from django.http import FileResponse, Http404
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
@@ -507,4 +507,6 @@ class InvoiceDownload(EventViewMixin, OrderDetailMixin, View):
|
|||||||
'now. Please try again in a few seconds.'))
|
'now. Please try again in a few seconds.'))
|
||||||
return redirect(self.get_order_url())
|
return redirect(self.get_order_url())
|
||||||
|
|
||||||
return redirect(invoice.file.url)
|
resp = FileResponse(invoice.file.file, content_type='application/pdf')
|
||||||
|
resp['Content-Disposition'] = 'attachment; filename="{}.pdf"'.format(invoice.number)
|
||||||
|
return resp
|
||||||
|
|||||||
Reference in New Issue
Block a user