2020-11-19 09:40:03 +01:00
|
|
|
from pretix.base.ticketoutput import BaseTicketOutput
|
|
|
|
|
2023-12-15 22:09:23 +01:00
|
|
|
|
2020-11-19 09:40:03 +01:00
|
|
|
class TextTicketOutput(BaseTicketOutput):
|
2023-12-15 22:09:23 +01:00
|
|
|
identifier = "tokens"
|
|
|
|
verbose_name = "Download token as in simple textfile"
|
|
|
|
download_button_text = "Download Token"
|
2020-11-19 09:40:03 +01:00
|
|
|
|
2023-12-15 22:09:23 +01:00
|
|
|
def generate(self, position):
|
|
|
|
token_export_format = "{name}: {secret}"
|
|
|
|
if position.event.settings.digitalitems_token_export_format:
|
|
|
|
token_export_format = (
|
|
|
|
position.event.settings.digitalitems_token_export_format
|
|
|
|
)
|
|
|
|
return (
|
|
|
|
"token.txt",
|
|
|
|
"text/plain",
|
|
|
|
token_export_format.format(
|
|
|
|
secret=position.secret, name=str(position.item.name)
|
|
|
|
),
|
|
|
|
)
|
2020-11-19 09:40:03 +01:00
|
|
|
|
2023-12-15 22:09:23 +01:00
|
|
|
def generate_order(self, order):
|
|
|
|
token_export_format = "{name}: {secret}"
|
|
|
|
if order.event.settings.digitalitems_token_export_format:
|
|
|
|
token_export_format = order.event.settings.digitalitems_token_export_format
|
|
|
|
return (
|
|
|
|
"tokens.txt",
|
|
|
|
"text/plain",
|
|
|
|
"\n".join(
|
|
|
|
token_export_format.format(
|
|
|
|
secret=position.secret, name=str(position.item.name)
|
|
|
|
)
|
|
|
|
for position in order.positions.all()
|
|
|
|
),
|
|
|
|
)
|