Writing a ticket output plugin
A ticket output is a method to offer a ticket (an order) for the user to download.
In this document, we will walk through the creation of a ticket output plugin. This is very similar to creating an export output.
Please read Creating a plugin first, if you haven’t already.
Output registration
The ticket output API does not make a lot of usage from signals, however, it
does use a signal to get a list of all available ticket outputs. Your plugin
should listen for this signal and return the subclass of eventyay.base.ticketoutput.BaseTicketOutput
that we’ll provide in this plugin:
1from django.dispatch import receiver
2
3from eventyay.base.signals import register_ticket_outputs
4
5
6@receiver(register_ticket_outputs, dispatch_uid="output_pdf")
7def register_ticket_output(sender, **kwargs):
8 from .ticketoutput import PdfTicketOutput
9 return PdfTicketOutput
The output class
- class eventyay.base.ticketoutput.BaseTicketOutput
The central object of each ticket output is the subclass of
BaseTicketOutput.- BaseTicketOutput.event
The default constructor sets this property to the event we are currently working for.
- BaseTicketOutput.settings
The default constructor sets this property to a
SettingsSandboxobject. You can use this object to store settings using itsgetandsetmethods. All settings you store are transparently prefixed, so you get your very own settings namespace.
- identifier
A short and unique identifier for this ticket output.
This is an abstract attribute, you must override this!
- verbose_name
A human-readable name for this ticket output.
This is an abstract attribute, you must override this!
- is_enabled
Whether this ticket output is enabled.
- multi_download_enabled
Whether downloading multiple tickets at once is enabled.
- settings_form_fields
A dictionary of form fields for the ticket output settings.
- settings_content_render(request)
Render additional content for the settings page.
- generate(position)
Generate a ticket for a single order position.
- Parameters:
position – The order position to generate a ticket for.
- Returns:
A tuple of (filename, content_type, file_content)
- generate_order(order)
Generate tickets for all positions in an order.
- Parameters:
order – The order to generate tickets for.
- Returns:
A tuple of (filename, content_type, file_content)
- download_button_text
The text for the download button.
- download_button_icon
The icon for the download button.
- multi_download_button_text
The text for the multi-download button.
- long_download_button_text
The long text for the download button.
- preview_allowed
Whether previewing tickets is allowed.
- javascript_required
Whether JavaScript is required to use this ticket output.