mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Swappable invoice renderers
This commit is contained in:
@@ -326,6 +326,24 @@ class Event(LoggedModel):
|
||||
providers[pp.identifier] = pp
|
||||
return providers
|
||||
|
||||
def get_invoice_renderers(self) -> dict:
|
||||
from ..signals import register_invoice_renderers
|
||||
|
||||
responses = register_invoice_renderers.send(self)
|
||||
renderers = {}
|
||||
for receiver, response in responses:
|
||||
if not isinstance(response, list):
|
||||
response = [response]
|
||||
for p in response:
|
||||
pp = p(self)
|
||||
renderers[pp.identifier] = pp
|
||||
return renderers
|
||||
|
||||
@property
|
||||
def invoice_renderer(self):
|
||||
irs = self.get_invoice_renderers()
|
||||
return irs[self.settings.invoice_renderer]
|
||||
|
||||
|
||||
def generate_invite_token():
|
||||
return get_random_string(length=32, allowed_chars=string.ascii_lowercase + string.digits)
|
||||
|
||||
@@ -9,9 +9,10 @@ from django.utils.functional import cached_property
|
||||
|
||||
def invoice_filename(instance, filename: str) -> str:
|
||||
secret = get_random_string(length=16, allowed_chars=string.ascii_letters + string.digits)
|
||||
return 'invoices/{org}/{ev}/{no}-{code}-{secret}.pdf'.format(
|
||||
return 'invoices/{org}/{ev}/{no}-{code}-{secret}.{ext}'.format(
|
||||
org=instance.event.organizer.slug, ev=instance.event.slug,
|
||||
no=instance.number, code=instance.order.code, secret=secret
|
||||
no=instance.number, code=instance.order.code, secret=secret,
|
||||
ext=filename.split('.')[-1]
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user