forked from CGM_Public/pretix_original
Swappable invoice renderers
This commit is contained in:
@@ -436,6 +436,11 @@ class InvoiceSettingsForm(SettingsForm):
|
||||
('paid', _('Automatically on payment')),
|
||||
)
|
||||
)
|
||||
invoice_renderer = forms.ChoiceField(
|
||||
label=_("Invoice style"),
|
||||
required=True,
|
||||
choices=[]
|
||||
)
|
||||
invoice_address_from = forms.CharField(
|
||||
widget=forms.Textarea(attrs={'rows': 5}), required=False,
|
||||
label=_("Your address"),
|
||||
@@ -472,6 +477,13 @@ class InvoiceSettingsForm(SettingsForm):
|
||||
help_text=_('We will show your logo with a maximal height and width of 2.5 cm.')
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
event = kwargs.get('obj')
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['invoice_renderer'].choices = [
|
||||
(r.identifier, r.verbose_name) for r in event.get_invoice_renderers().values()
|
||||
]
|
||||
|
||||
|
||||
class MailSettingsForm(SettingsForm):
|
||||
mail_prefix = forms.CharField(
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
{% bootstrap_field form.invoice_address_vatid layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_numbers_consecutive layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_generate layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_renderer layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_language layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_address_from layout="horizontal" %}
|
||||
{% bootstrap_field form.invoice_introductory_text layout="horizontal" %}
|
||||
|
||||
@@ -310,9 +310,9 @@ class InvoicePreview(EventPermissionRequiredMixin, View):
|
||||
permission = 'can_change_event_settings'
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
pdf = build_preview_invoice_pdf(request.event)
|
||||
resp = HttpResponse(pdf, content_type='application/pdf')
|
||||
resp['Content-Disposition'] = 'attachment; filename="invoice-preview.pdf"'
|
||||
fname, ftype, fcontent = build_preview_invoice_pdf(request.event)
|
||||
resp = HttpResponse(fcontent, content_type=ftype)
|
||||
resp['Content-Disposition'] = 'attachment; filename="{}"'.format(fname)
|
||||
return resp
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user