Core Modules Reference
This section documents the core modules of the unified eventyay system.
Configuration & Settings
Settings Management
- eventyay.config.settings_helpers.build_db_tls_config(config, db_backend)
- eventyay.config.settings_helpers.build_redis_tls_config(config)
Channels & Sales
Sales Channels
- class eventyay.base.channels.SalesChannel
Bases:
object- property icon: str
The name of a Font Awesome icon to represent this channel
- property identifier: str
The internal identifier of this sales channel.
- property payment_restrictions_supported: bool
If this property is
True, organizers can restrict the usage of payment providers to this sales channel.Example: pretixPOS provides its own sales channel, ignores the configured payment providers completely and handles payments locally. Therefor, this property should be set to
Falsefor the pretixPOS sales channel as the event organizer cannot restrict the usage of any payment provider through the backend.
- property testmode_supported: bool
Indication, if a saleschannels supports test mode orders
- property unlimited_products_per_order: bool
If this property is
True, purchases made using this sales channel are not limited to the maximum amount of items defined in the event settings.
- property verbose_name: str
A human-readable name of this sales channel.
- eventyay.base.channels.get_all_sales_channels()
The default sales channel is:
- class eventyay.base.channels.WebshopSalesChannel
Bases:
SalesChannel- icon = 'globe'
- identifier = 'web'
- verbose_name = 'Online shop'
Payment Processing
Base Payment Provider
- class eventyay.base.payment.BasePaymentProvider(event: Event)
Bases:
objectThis is the base class for all payment providers.
- property abort_pending_allowed: bool
Whether or not a user can abort a payment in pending state to switch to another payment method. This returns
Falseby default which is no guarantee that aborting a pending payment can never happen, it just hides the frontend button to avoid users accidentally committing double payments.
- api_payment_details(payment: OrderPayment)
Will be called to populate the
detailsparameter of the payment in the REST API.- Parameters:
payment – The payment in question.
- Returns:
A serializable dictionary
- calculate_fee(price: Decimal) Decimal
Calculate the fee for this payment provider which will be added to final price before fees (but after taxes). It should include any taxes. The default implementation makes use of the setting
_fee_absfor an absolute fee and_fee_percentfor a percentage.- Parameters:
price – The total value without the payment method fee, after taxes.
- cancel_payment(payment: OrderPayment)
Will be called to cancel a payment. The default implementation just sets the payment state to canceled, but in some cases you might want to notify an external provider.
On success, you should set
payment.state = OrderPayment.PAYMENT_STATE_CANCELED(or call the super method). On failure, you should raise a PaymentException.
- checkout_confirm_render(request, order: Order = None) str
If the user has successfully filled in their payment data, they will be redirected to a confirmation page which lists all details of their order for a final review. This method should return the HTML which should be displayed inside the ‘Payment’ box on this page.
In most cases, this should include a short summary of the user’s input and a short explanation on how the payment process will continue.
- Parameters:
order – Only set when this is a change to a new payment method for an existing order.
- checkout_prepare(request: HttpRequest, cart: Dict[str, Any]) bool | str
Will be called after the user selects this provider as their payment method. If you provided a form to the user to enter payment data, this method should at least store the user’s input into their session.
This method should return
Falseif the user’s input was invalid,Trueif the input was valid and the frontend should continue with default behavior or a string containing a URL if the user should be redirected somewhere else.On errors, you should use Django’s message framework to display an error message to the user (or the normal form validation error messages).
The default implementation stores the input into the form returned by
payment_form()in the user’s session.If your payment method requires you to redirect the user to an external provider, this might be the place to do so.
Important
If this is called, the user has not yet confirmed their order. You may NOT do anything which actually moves money.
- Parameters:
cart –
This dictionary contains at least the following keys:
- positions:
A list of
CartPositionobjects that are annotated with the special attributescountandtotalbecause multiple objects of the same content are grouped into one.- raw:
The raw list of
CartPositionobjects in the users cart- total:
The overall total including the fee for the payment method.
- payment_fee:
The fee for the payment method.
- execute_payment(request: HttpRequest, payment: OrderPayment) str
After the user has confirmed their purchase, this method will be called to complete the payment process. This is the place to actually move the money if applicable. You will be passed an
pretix.base.models.OrderPaymentobject that contains the amount of money that should be paid.If you need any special behavior, you can return a string containing the URL the user will be redirected to. If you are done with your process you should return the user to the order’s detail page.
If the payment is completed, you should call
payment.confirm(). Please note that this might raise aQuota.QuotaExceededExceptionif (and only if) the payment term of this order is over and some of the items are sold out. You should use the exception message to display a meaningful error to the user.The default implementation just returns
Noneand therefore leaves the order unpaid. The user will be redirected to the order’s detail page by default.On errors, you should raise a
PaymentException.- Parameters:
order – The order object
payment – An
OrderPaymentinstance
- execute_refund(refund: OrderRefund)
Will be called to execute an refund. Note that refunds have an amount property and can be partial.
This should transfer the money back (if possible). On success, you should call
refund.done(). On failure, you should raise a PaymentException.
- property identifier: str
A short and unique identifier for this payment provider. This should only contain lowercase letters and in most cases will be the same as your package name.
- is_allowed(request: HttpRequest, total: Decimal = None) bool
You can use this method to disable this payment provider for certain groups of users, products or other criteria. If this method returns
False, the user will not be able to select this payment method. This will only be called during checkout, not on retrying.The default implementation checks for the _availability_date setting to be either unset or in the future and for the _total_max and _total_min requirements to be met. It also checks the
_restrict_countriesand_restrict_to_sales_channelssetting.- Parameters:
total – The total value without the payment method fee, after taxes.
Changed in version 1.17.0: The
totalparameter has been added. For backwards compatibility, this method is called again without this parameter if it raises aTypeErroron first try.
- property is_enabled: bool
Returns whether or whether not this payment provider is enabled. By default, this is determined by the value of the
_enabledsetting.
- is_implicit(request: HttpRequest) bool
Returns whether or whether not this payment provider is an “implicit” payment provider that will always and unconditionally be used if is_allowed() returns True and does not require any input. This is intended to be used by the FreeOrderProvider, which skips the payment choice page. By default, this returns
False. Please do not set this if you don’t know exactly what you are doing.
- property is_meta: bool
Returns whether or whether not this payment provider is a “meta” payment provider that only works as a settings holder for other payment providers and should never be used directly. This is a trick to implement payment gateways with multiple payment methods but unified payment settings. Take a look at the built-in stripe provider to see how this might be used. By default, this returns
False.
- matching_id(payment: OrderPayment)
Will be called to get an ID for matching this payment when comparing pretix records with records of an external source. This should return the main transaction ID for your API.
- Parameters:
payment – The payment in question.
- Returns:
A string or None
- new_refund_control_form_process(request: HttpRequest, amount: Decimal, order: Order) OrderRefund
Process a backend user’s request to initiate a new refund with an amount of
amountfororder.This method should parse the input provided to the form created and either raise
ValidationErroror return anOrderRefundobject increatedstate that has not yet been saved to the database. The system will then callexecute_refundon that object.
- new_refund_control_form_render(request: HttpRequest, order: Order) str
Render a form that will be shown to backend users when trying to create a new refund.
Usually, refunds are created from an existing payment object, e.g. if there is a credit card payment and the credit card provider returns
Truefrompayment_refund_supported, the system will automatically create anOrderRefundand callexecute_refundon that payment. This method can and should not be used in that situation! Instead, by implementing this method you can add a refund flow for this payment provider that starts without an existing payment. For example, even though an order was paid by credit card, it could easily be refunded by SEPA bank transfer. In that case, the SEPA bank transfer provider would implement this method and return a form that asks for the IBAN.This method should return HTML or
None. All form fields should have a globally unique name.
- order_change_allowed(order: Order) bool
Will be called to check whether it is allowed to change the payment method of an order to this one.
The default implementation checks for the _availability_date setting to be either unset or in the future, as well as for the _total_max, _total_min and _restricted_countries settings.
- Parameters:
order – The order object
- order_pending_mail_render(order: Order, payment: OrderPayment) str
After the user has submitted their order, they will receive a confirmation email. You can return a string from this method if you want to add additional information to this email.
- Parameters:
order – The order object
payment – The payment object
- payment_control_render(request: HttpRequest, payment: OrderPayment) str
Will be called if the event administrator views the details of a payment.
It should return HTML code containing information regarding the current payment status and, if applicable, next steps.
The default implementation returns an empty string.
- Parameters:
order – The order object
- payment_control_render_short(payment: OrderPayment) str
Will be called if the event administrator performs an action on the payment. Should return a very short version of the payment method. Usually, this should return e.g. a transaction ID or account identifier, but no information on status, dates, etc.
The default implementation falls back to
payment_presale_render.- Parameters:
order – The order object
- payment_form(request: HttpRequest) Form
This is called by the default implementation of
payment_form_render()to obtain the form that is displayed to the user during the checkout process. The default implementation constructs the form usingpayment_form_fieldsand sets appropriate prefixes for the form and all fields and fills the form with data form the user’s session.If you overwrite this, we strongly suggest that you inherit from
PaymentProviderForm(from this module) that handles some nasty issues about required fields for you.
- payment_form_class
alias of
PaymentProviderForm
- property payment_form_fields: dict
This is used by the default implementation of
payment_form(). It should return an object similar tosettings_form_fields.The default implementation returns an empty dictionary.
- payment_form_render(request: HttpRequest, total: Decimal, order: Order = None) str
When the user selects this provider as their preferred payment method, they will be shown the HTML you return from this method.
The default implementation will call
payment_form()and render the returned form. If your payment method doesn’t require the user to fill out form fields, you should just return a paragraph of explanatory text.- Parameters:
order – Only set when this is a change to a new payment method for an existing order.
- payment_is_valid_session(request: HttpRequest) bool
This is called at the time the user tries to place the order. It should return
Trueif the user’s session is valid and all data your payment provider requires in future steps is present.
- payment_partial_refund_supported(payment: OrderPayment) bool
Will be called to check if the provider supports automatic partial refunding for this payment.
- payment_pending_render(request: HttpRequest, payment: OrderPayment) str
Render customer-facing instructions on how to proceed with a pending payment
- Returns:
HTML
- payment_prepare(request: HttpRequest, payment: OrderPayment) bool | str
Will be called if the user retries to pay an unpaid order (after the user filled in e.g. the form returned by
payment_form()) or if the user changes the payment method.It should return and report errors the same way as
checkout_prepare(), but receives anOrderobject instead of a cart object.Note: The
Orderobject given to this method might be different from the version stored in the database as it’s total will already contain the payment fee for the new payment method.
- payment_presale_render(payment: OrderPayment) str
Will be called if the ticket customer views the details of a payment. This is currently used e.g. when the customer requests a refund to show which payment method is used for the refund. This should only include very basic information about the payment, such as “VISA card ****9999”, and never raw payment information.
The default implementation returns the public name of the payment provider.
- Parameters:
order – The order object
- payment_refund_supported(payment: OrderPayment) bool
Will be called to check if the provider supports automatic refunding for this payment.
- property priority: int
Returns a priority that is used for sorting payment providers. Higher priority means higher up in the list. Default to 100. Providers with same priority are sorted alphabetically.
- property public_name: str
A human-readable name for this payment provider to be shown to the public. This should be short but self-explaining. Good examples include ‘Bank transfer’ and ‘Credit card’, but ‘Credit card via Stripe’ might be to explicit. By default, this is the same as
verbose_name
- refund_control_render(request: HttpRequest, refund: OrderRefund) str
Will be called if the event administrator views the details of a refund.
It should return HTML code containing information regarding the current refund status and, if applicable, next steps.
The default implementation returns an empty string.
- Parameters:
refund – The refund object
- render_invoice_text(order: Order, payment: OrderPayment) str
This is called when an invoice for an order with this payment provider is generated. The default implementation returns the content of the _invoice_text configuration variable (an I18nString), or an empty string if unconfigured. For paid orders, the default implementation always renders a string stating that the invoice is already paid.
- property requires_invoice_immediately
Return whether this payment method requires an invoice to exist for an order, even though the event is configured to only create invoices for paid orders. By default this is False, but it might be overwritten for e.g. bank transfer. execute_payment is called after the invoice is created.
- settings_content_render(request: HttpRequest) str
When the event’s administrator visits the event configuration page, this method is called. It may return HTML containing additional information that is displayed below the form fields configured in
settings_form_fields.
- settings_form_clean(cleaned_data)
Overriding this method allows you to inject custom validation into the settings form.
- Parameters:
cleaned_data – Form data as per previous validations.
- Returns:
Please return the modified cleaned_data
- property settings_form_fields: dict
When the event’s administrator visits the event configuration page, this method is called to return the configuration fields available.
It should therefore return a dictionary where the keys should be (unprefixed) settings keys and the values should be corresponding Django form fields.
The default implementation returns the appropriate fields for the
_enabled,_fee_abs,_fee_percentand_availability_datesettings mentioned above.We suggest that you return an
OrderedDictobject instead of a dictionary and make use of the default implementation. Your implementation could look like this:1@property 2def settings_form_fields(self): 3 return OrderedDict( 4 list(super().settings_form_fields.items()) + [ 5 ('bank_details', 6 forms.CharField( 7 widget=forms.Textarea, 8 label=_('Bank account details'), 9 required=False 10 )) 11 ] 12 )
Warning
It is highly discouraged to alter the
_enabledfield of the default implementation.
- shred_payment_info(obj: OrderPayment | OrderRefund)
When personal data is removed from an event, this method is called to scrub payment-related data from a payment or refund. By default, it removes all info from the
infoattribute. You can override this behavior if you want to retain attributes that are not personal data on their own, i.e. a reference to a transaction in an external system. You can also override this to scrub more data, e.g. data from external sources that is saved in LogEntry objects or other places.- Parameters:
order – An order
- property test_mode_message: str
If this property is set to a string, this will be displayed when this payment provider is selected while the event is in test mode. You should use it to explain to your user how your plugin behaves, e.g. if it falls back to a test mode automatically as well or if actual payments will be performed.
If you do not set this (or, return
None), pretix will show a default message warning the user that this plugin does not support test mode payments.
- property verbose_name: str
A human-readable name for this payment provider. This should be short but self-explaining. Good examples include ‘Bank transfer’ and ‘Credit card via Stripe’.
Payment Exceptions
- exception eventyay.base.payment.PaymentException
Bases:
Exception
Invoice Generation
See eventyay.base.services.invoices for invoice generation functions.
Ticket Output
Ticket Output Providers
- class eventyay.base.ticketoutput.BaseTicketOutput(event: Event)
Bases:
objectThis is the base class for all ticket outputs.
- property download_button_icon: str
The Font Awesome icon on the download button in the frontend.
- property download_button_text: str
The text on the download button in the frontend.
- generate(position: OrderPosition) Tuple[str, str, str]
This method should generate the download file and return a tuple consisting of a filename, a file type and file content. The extension will be taken from the filename which is otherwise ignored.
Alternatively, you can pass a tuple consisting of an arbitrary string,
text/uri-listand a single URL. In this case, the user will be redirected to this link instead of being asked to download a generated file.Note
If the event uses the event series feature (internally called subevents) and your generated ticket contains information like the event name or date, you probably want to display the properties of the subevent. A common pattern to do this would be a declaration
ev = position.subevent or position.order.eventand then access properties that are present on both classes likeev.nameorev.date_from.Note
Should you elect to use the URI redirection feature instead of offering downloads, you should also set the
multi_download_enabled-property toFalse.
- generate_order(order: Order) Tuple[str, str, str]
This method is the same as order() but should not generate one file per order position but instead one file for the full order.
This method is optional to implement. If you don’t implement it, the default implementation will offer a zip file of the generate() results for the order positions.
This method should generate a download file and return a tuple consisting of a filename, a file type and file content. The extension will be taken from the filename which is otherwise ignored.
If you override this method, make sure that positions that are addons (i.e.
addon_tois set) are only outputted if the event settingticket_download_addonsis active. Do the same for positions that are non-admission withoutticket_download_nonadmactive. If you want, you can just iterate overorder.positions_with_ticketswhich applies the appropriate filters for you.
- property identifier: str
A short and unique identifier for this ticket output. This should only contain lowercase letters and in most cases will be the same as your package name.
- property is_enabled: bool
Returns whether or whether not this output is enabled. By default, this is determined by the value of the
_enabledsetting.
- property javascript_required: bool
If this property is set to true, the download-button for this ticket-type will not be displayed when the user’s browser has JavaScript disabled.
Defaults to
False
- property long_download_button_text: str
The text on the large download button in the frontend.
- property multi_download_button_text: str
The text on the multi download button in the frontend.
- property multi_download_enabled: bool
Returns whether or not the
generate_ordermethod may be called. ReturnsTrueby default.
- property preview_allowed: bool
By default, the
generate()method is called for generating a preview in the pretix backend. In case your plugin cannot generate previews for any reason, you can manually disable it here.
- settings_content_render(request: HttpRequest) str
When the event’s administrator visits the event configuration page, this method is called. It may return HTML containing additional information that is displayed below the form fields configured in
settings_form_fields.
- property settings_form_fields: dict
When the event’s administrator visits the event configuration page, this method is called to return the configuration fields available.
It should therefore return a dictionary where the keys should be (unprefixed) settings keys and the values should be corresponding Django form fields.
The default implementation returns the appropriate fields for the
_enabledsetting mentioned above.We suggest that you return an
OrderedDictobject instead of a dictionary and make use of the default implementation. Your implementation could look like this:1@property 2def settings_form_fields(self): 3 return OrderedDict( 4 list(super().settings_form_fields.items()) + [ 5 ('paper_size', 6 forms.CharField( 7 label=_('Paper size'), 8 required=False 9 )) 10 ] 11 )
Warning
It is highly discouraged to alter the
_enabledfield of the default implementation.
- property verbose_name: str
A human-readable name for this ticket output. This should be short but self-explanatory. Good examples include ‘PDF tickets’ and ‘Passbook’.
Data Export
Exporters
- class eventyay.base.exporter.BaseExporter(event, progress_callback=<function BaseExporter.<lambda>>)
Bases:
objectThis is the base class for all data exporters
- property export_form_fields: dict
When the event’s administrator visits the export page, this method is called to return the configuration fields available.
It should therefore return a dictionary where the keys should be field names and the values should be corresponding Django form fields.
We suggest that you return an
OrderedDictobject instead of a dictionary. Your implementation could look like this:1@property 2def export_form_fields(self): 3 return OrderedDict( 4 [ 5 ('tab_width', 6 forms.IntegerField( 7 label=_('Tab width'), 8 default=4 9 )) 10 ] 11 )
- property identifier: str
A short and unique identifier for this exporter. This should only contain lowercase letters and in most cases will be the same as your package name.
- render(form_data: dict) Tuple[str, str, bytes]
Render the exported file and return a tuple consisting of a filename, a file type and file content.
- Parameters:
form_data (dict) – The form data of the export details form
output_file – You can optionally accept a parameter that will be given a file handle to write the output to. In this case, you can return None instead of the file content.
Note: If you use a
ModelChoiceField(or aModelMultipleChoiceField), theform_datawill not contain the model instance but only it’s primary key (or a list of primary keys) for reasons of internal serialization when using background tasks.
- property verbose_name: str
A human-readable name for this exporter. This should be short but self-explaining. Good examples include ‘JSON’ or ‘Microsoft Excel’.
- class eventyay.base.exporter.ListExporter(event, progress_callback=<function BaseExporter.<lambda>>)
Bases:
BaseExporter- class ProgressSetTotal(total)
Bases:
tuple- total
Alias for field number 0
- property additional_form_fields: dict
- property export_form_fields: dict
When the event’s administrator visits the export page, this method is called to return the configuration fields available.
It should therefore return a dictionary where the keys should be field names and the values should be corresponding Django form fields.
We suggest that you return an
OrderedDictobject instead of a dictionary. Your implementation could look like this:1@property 2def export_form_fields(self): 3 return OrderedDict( 4 [ 5 ('tab_width', 6 forms.IntegerField( 7 label=_('Tab width'), 8 default=4 9 )) 10 ] 11 )
- get_filename()
- iterate_list(form_data)
- render(form_data: dict, output_file=None) Tuple[str, str, bytes]
Render the exported file and return a tuple consisting of a filename, a file type and file content.
- Parameters:
form_data (dict) – The form data of the export details form
output_file – You can optionally accept a parameter that will be given a file handle to write the output to. In this case, you can return None instead of the file content.
Note: If you use a
ModelChoiceField(or aModelMultipleChoiceField), theform_datawill not contain the model instance but only it’s primary key (or a list of primary keys) for reasons of internal serialization when using background tasks.
- class eventyay.base.exporter.MultiSheetListExporter(event, progress_callback=<function BaseExporter.<lambda>>)
Bases:
ListExporter- property export_form_fields: dict
When the event’s administrator visits the export page, this method is called to return the configuration fields available.
It should therefore return a dictionary where the keys should be field names and the values should be corresponding Django form fields.
We suggest that you return an
OrderedDictobject instead of a dictionary. Your implementation could look like this:1@property 2def export_form_fields(self): 3 return OrderedDict( 4 [ 5 ('tab_width', 6 forms.IntegerField( 7 label=_('Tab width'), 8 default=4 9 )) 10 ] 11 )
- iterate_list(form_data)
- iterate_sheet(form_data, sheet)
- render(form_data: dict, output_file=None) Tuple[str, str, bytes]
Render the exported file and return a tuple consisting of a filename, a file type and file content.
- Parameters:
form_data (dict) – The form data of the export details form
output_file – You can optionally accept a parameter that will be given a file handle to write the output to. In this case, you can return None instead of the file content.
Note: If you use a
ModelChoiceField(or aModelMultipleChoiceField), theform_datawill not contain the model instance but only it’s primary key (or a list of primary keys) for reasons of internal serialization when using background tasks.
- property sheets
Data Shredding
- class eventyay.base.shredder.BaseDataShredder(event: Event)
Bases:
objectThis is the base class for all data shredders.
- property description: str
A more detailed description of what this shredder does. Can contain HTML.
- generate_files() List[Tuple[str, str, str]]
This method is called to export the data that is about to be shred and return a list of tuples consisting of a filename, a file type and file content.
You can also implement this as a generator and
yieldthose tuples instead of returning a list of them.
- property identifier: str
A short and unique identifier for this shredder. This should only contain lowercase letters and in most cases will be the same as your package name.
- property require_download_confirmation
Indicates whether the data of this shredder needs to be downloaded, before it is actually shredded. By default this value is equal to the tax relevant flag.
- shred_data()
This method is called to actually remove the data from the system. You should remove any database objects here.
You should never delete
LogEntryobjects, but you might modify them to remove personal data. In this case, set theLogEntry.shreddedattribute toTrueto show that this is no longer original log data.
- property tax_relevant
Indicates whether this removes potentially tax-relevant data.
- property verbose_name: str
A human-readable name for what this shredder removes. This should be short but self-explanatory. Good examples include ‘E-Mail addresses’ or ‘Invoices’.
- exception eventyay.base.shredder.ShredError(*args)
Bases:
LazyLocaleException
- eventyay.base.shredder.shred_constraints(event: Event)
Email & Notifications
Email Context
- eventyay.base.email.get_email_context(**kwargs)
- eventyay.base.email.get_available_placeholders(event: Event, base_parameters: Iterable[str]) dict[str, BaseMailTextPlaceholder]
Mail Services
- exception eventyay.base.services.mail.SendMailException
Bases:
Exception
Notification Services
- class eventyay.base.notifications.ActionRequiredNotificationType(event: Event = None)
Bases:
NotificationType- action_type = 'pretix.event.action_required'
- build_notification(logentry: LogEntry)
This is the main function that you should override. It is supposed to turn a log entry object into a notification object that can then be rendered e.g. into an email.
- required_permission = 'can_change_orders'
- verbose_name = 'Administrative action required'
- class eventyay.base.notifications.Notification(event: Event, title: str, detail: str = None, url: str = None)
Bases:
objectRepresents a notification that is sent/shown to a user. A notification consists of:
one
eventreferenceone
titletext that is shown e.g. in the email subject or in a headlineoptionally one
detailtext that may or may not be shown depending on the notification methodoptionally one
urlthat should be absolute and point to the context of an notification (e.g. an order)optionally a number of attributes consisting of a title and a value that can be used to add additional details to the notification (e.g. “Customer: ABC”)
optionally a number of actions that may or may not be shown as buttons depending on the notification method, each consisting of a button label and an absolute URL to point to.
- add_action(label, url)
Add an action to the notification, defined by a label and an url. An example could be a label of “View order” and an url linking to the order detail page.
- add_attribute(title, value)
Add an attribute to the notification, defined by a title and a value. An example could be a title of “Date” and a value of “2017-12-14”.
- class eventyay.base.notifications.NotificationAction(label, url)
Bases:
tuple- label
Alias for field number 0
- url
Alias for field number 1
- class eventyay.base.notifications.NotificationAttribute(title, value)
Bases:
tuple- title
Alias for field number 0
- value
Alias for field number 1
- class eventyay.base.notifications.NotificationType(event: Event = None)
Bases:
object- property action_type: str
The action_type string that this notification handles, for example
"pretix.event.order.paid". Only one notification type should be registered per action type.
- build_notification(logentry: LogEntry) Notification
This is the main function that you should override. It is supposed to turn a log entry object into a notification object that can then be rendered e.g. into an email.
- property required_permission: str
The permission a user needs to hold for the related event to receive this notification.
- property verbose_name: str
A human-readable name of this notification type.
- class eventyay.base.notifications.ParametrizedOrderNotificationType(event, action_type, verbose_name, title)
Bases:
NotificationType- property action_type
The action_type string that this notification handles, for example
"pretix.event.order.paid". Only one notification type should be registered per action type.
- build_notification(logentry: LogEntry)
This is the main function that you should override. It is supposed to turn a log entry object into a notification object that can then be rendered e.g. into an email.
- required_permission = 'can_view_orders'
- property verbose_name
A human-readable name of this notification type.
- eventyay.base.notifications.get_all_notification_types(event=None)
- eventyay.base.notifications.register_default_notification_types(sender, **kwargs)
Middleware
- class eventyay.base.middleware.CustomCommonMiddleware(get_response)
Bases:
CommonMiddleware- get_full_path_with_slash(request)
Raise an error regardless of DEBUG mode when in POST, PUT, or PATCH.
- class eventyay.base.middleware.LocaleMiddleware(get_response)
Bases:
MiddlewareMixinThis middleware sets the correct locale and timezone for a request.
- process_request(request: HttpRequest)
- process_response(request: HttpRequest, response: HttpResponse)
- class eventyay.base.middleware.SecurityMiddleware(get_response)
Bases:
MiddlewareMixin- CSP_EXEMPT = ('/api/v1/docs/',)
- process_response(request, resp)
- eventyay.base.middleware.get_default_language()
- eventyay.base.middleware.get_language_from_browser(request: HttpRequest) str
- eventyay.base.middleware.get_language_from_cookie(request: HttpRequest) str
- eventyay.base.middleware.get_language_from_event(request: HttpRequest) str
- eventyay.base.middleware.get_language_from_request(request: HttpRequest) str
Analyzes the request to find what language the user wants the system to show. Only languages listed in settings.LANGUAGES are taken into account. If the user requests a sublanguage where we have a main language, we send out the main language.
- eventyay.base.middleware.get_language_from_user_settings(request: HttpRequest) str
- class eventyay.control.middleware.AuditLogMiddleware(get_response)
Bases:
object
- class eventyay.control.middleware.PermissionMiddleware(get_response=None)
Bases:
objectThis middleware enforces all requests to the control app to require login. Additionally, it enforces all requests to “control:event.” URLs to be for an event the user has basic access to.
- EXCEPTIONS = ('auth.login', 'auth.login.2fa', 'auth.register', 'auth.forgot', 'auth.forgot.recover', 'auth.invite', 'user.settings.notifications.off', 'oauth2_provider')
- EXCEPTIONS_2FA = ('eventyay_common:account.2fa', 'eventyay_common:account.2fa.add', 'eventyay_common:account.2fa.enable', 'eventyay_common:account.2fa.disable', 'eventyay_common:account.2fa.regenemergency', 'eventyay_common:account.2fa.confirm.totp', 'eventyay_common:account.2fa.confirm.webauthn', 'eventyay_common:account.2fa.delete', 'auth.logout', 'user.reauth')
Multi-domain middleware is located in eventyay.multidomain.middleware.
Internationalization
- class eventyay.base.i18n.LazyCurrencyNumber(value, currency)
Bases:
object
- class eventyay.base.i18n.LazyDate(value)
Bases:
object
- class eventyay.base.i18n.LazyExpiresDate(expires)
Bases:
object
- exception eventyay.base.i18n.LazyLocaleException(*args)
Bases:
Exception
- class eventyay.base.i18n.LazyNumber(value, decimal_pos=2)
Bases:
object
- eventyay.base.i18n.get_babel_locale()
- eventyay.base.i18n.get_language_without_region(lng=None)
Returns the currently active language, but strips what pretix calls a
region. For example, if the currently active language isen-us, you will be returnedensince pretix does not ship with separate language files foren-us. If the currently active language ispt-br, you will be returnedpt-brsince there are separate language files forpt-br.tl;dr: You will be always passed a language that is defined in settings.LANGUAGES.
- eventyay.base.i18n.language(lng, region=None)
Temporarily change the active language to
lng. Will automatically be rolled back when the context manager returns.You can optionally pass a “region”. For example, if you pass
enaslngandUSasregion, the active language will been-us, which will mostly affect date/time formatting. If you pass alngthat already contains a region, e.g.pt-br, theregionattribute will be ignored.
- eventyay.helpers.i18n.get_format_without_seconds(format_name)
- eventyay.helpers.i18n.get_javascript_format(format_name)
- eventyay.helpers.i18n.get_javascript_format_without_seconds(format_name)
- eventyay.helpers.i18n.get_javascript_output_format(format_name)
- eventyay.helpers.i18n.get_moment_locale(locale=None)
- eventyay.helpers.i18n.i18ncomp(query)
Utilities
Money & Decimal
- eventyay.base.decimal.round_decimal(dec, currency=None, places_dict={'BIF': 0, 'CLP': 0, 'DJF': 0, 'GNF': 0, 'JPY': 0, 'KMF': 0, 'KRW': 0, 'MGA': 0, 'PYG': 0, 'RWF': 0, 'VND': 0, 'VUV': 0, 'XAF': 0, 'XOF': 0, 'XPF': 0})
- class eventyay.helpers.money.DecimalTextInput(*args, **kwargs)
Bases:
TextInput- format_value(value)
Return a value as it should appear when rendered in a template.
- property media
- eventyay.helpers.money.change_decimal_field(field, currency)
Date & Time
- class eventyay.base.reldate.ModelRelativeDateTimeField(*args, **kwargs)
Bases:
CharField- form_class
alias of
RelativeDateTimeField
- formfield(**kwargs)
Return a django.forms.Field instance for this field.
- from_db_value(value, expression, connection)
- get_prep_value(value)
Perform preliminary non-db specific value checks and conversions.
- to_python(value)
Convert the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can’t be converted. Return the converted value. Subclasses should override this.
- class eventyay.base.reldate.RelativeDate(days_before, minutes_before, time, base_date_name)
Bases:
tuple- base_date_name
Alias for field number 3
- days_before
Alias for field number 0
- minutes_before
Alias for field number 1
- time
Alias for field number 2
- class eventyay.base.reldate.RelativeDateField(*args, **kwargs)
Bases:
RelativeDateTimeField- clean(value)
Validate every value in the given list. A value is validated against the corresponding Field in self.fields.
For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), clean() would call DateField.clean(value[0]) and TimeField.clean(value[1]).
- compress(data_list)
Return a single value for the given list of values. The values can be assumed to be valid.
For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), this might return a datetime object created by combining the date and time in data_list.
- class eventyay.base.reldate.RelativeDateTimeField(*args, **kwargs)
Bases:
MultiValueField- clean(value)
Validate every value in the given list. A value is validated against the corresponding Field in self.fields.
For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), clean() would call DateField.clean(value[0]) and TimeField.clean(value[1]).
- compress(data_list)
Return a single value for the given list of values. The values can be assumed to be valid.
For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), this might return a datetime object created by combining the date and time in data_list.
- set_event(event)
- class eventyay.base.reldate.RelativeDateTimeWidget(*args, **kwargs)
Bases:
MultiWidget- decompress(value)
Return a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
- get_context(name, value, attrs)
- property media
Media for a multiwidget is the combination of all media of the subwidgets.
- template_name = 'pretixbase/forms/widgets/reldatetime.html'
- class eventyay.base.reldate.RelativeDateWidget(*args, **kwargs)
Bases:
RelativeDateTimeWidget- decompress(value)
Return a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
- property media
Media for a multiwidget is the combination of all media of the subwidgets.
- template_name = 'pretixbase/forms/widgets/reldate.html'
- class eventyay.base.reldate.RelativeDateWrapper(data: datetime | RelativeDate)
Bases:
objectThis contains information on a date that might be relative to an event. This means that the underlying data is either a fixed date or a number of days and a wall clock time to calculate the date based on a base point.
The base point can be the date_from, date_to, date_admission, presale_start or presale_end attribute of an event or subevent. If the respective attribute is not set,
date_fromwill be used.- date(event) date
- datetime(event) datetime
- classmethod from_string(input: str)
- to_string() str
- class eventyay.base.reldate.SerializerRelativeDateField(*args, **kwargs)
Bases:
CharField- to_internal_value(data)
Transform the incoming primitive data into a native value.
- to_representation(value: RelativeDateWrapper)
Transform the outgoing native value into primitive data.
- class eventyay.base.reldate.SerializerRelativeDateTimeField(*args, **kwargs)
Bases:
CharField- to_internal_value(data)
Transform the incoming primitive data into a native value.
- to_representation(value: RelativeDateWrapper)
Transform the outgoing native value into primitive data.
- eventyay.helpers.daterange.daterange(df, dt)
Validation
- class eventyay.base.validators.EmailBanlistValidator(*args, **kwargs)
Bases:
BanlistValidator- banlist = ['info@eventyay.com']
- deconstruct()
Return a 3-tuple of class import path, positional arguments, and keyword arguments.
- class eventyay.base.validators.EventSlugBanlistValidator(*args, **kwargs)
Bases:
BanlistValidator- banlist = ['download', 'healthcheck', 'locale', 'control', 'redirect', 'jsi18n', 'metrics', '_global', '__debug__', 'api', 'events', 'csp_report', 'widget']
- deconstruct()
Return a 3-tuple of class import path, positional arguments, and keyword arguments.
- class eventyay.base.validators.OrganizerSlugBanlistValidator(*args, **kwargs)
Bases:
BanlistValidator- banlist = ['download', 'healthcheck', 'locale', 'control', 'pretixdroid', 'redirect', 'jsi18n', 'metrics', '_global', '__debug__', 'about', 'api', 'csp_report', 'widget']
- deconstruct()
Return a 3-tuple of class import path, positional arguments, and keyword arguments.
Cache
- class eventyay.base.cache.NamespacedCache(prefixkey: str, cache: str = 'default')
Bases:
object- clear() None
- close()
- decr(key: str, by: int = 1)
- delete(key: str)
- delete_many(keys: List[str])
- get(key: str) str
- get_many(keys: List[str]) Dict[str, str]
- get_or_set(key: str, default: Callable, timeout=300) str
- incr(key: str, by: int = 1)
- set(key: str, value: str, timeout: int = 300)
- set_many(values: Dict[str, str], timeout=300)
- class eventyay.base.cache.ObjectRelatedCache(obj: Model, cache: str = 'default')
Bases:
NamespacedCacheThis object behaves exactly like the cache implementations by Django but with one important difference: It stores all keys related to a certain object, so you pass an object when creating this object and if you store data in this cache, it is only stored for this object. The main purpose of this is to be able to flush all cached data related to this object at once.
The ObjectRelatedCache instance itself is stateless, all state is stored in the cache backend, so you can instantiate this class as many times as you want.
- class eventyay.helpers.cache.CustomDummyCache(host, *args, **kwargs)
Bases:
DummyCache- get_or_set(key, default, timeout=<object object>, version=None)
Fetch a given key from the cache. If the key does not exist, add the key and set it to the default value. The default value can also be any callable. If timeout is given, use that timeout for the key; otherwise use the default cache timeout.
Return the value of the key stored or retrieved.
Storage
- class eventyay.base.storage.NoMapManifestStaticFilesStorage(*args, **kwargs)
Bases:
ManifestStaticFilesStorage- post_process(paths, dry_run=False, **options)
Post process the given dictionary of files (called from collectstatic).
Processing is actually two separate operations:
renaming files to include a hash of their content for cache-busting, and copying those files to the target storage.
adjusting files which contain references to other files so they refer to the cache-busting filenames.
If either of these are performed on a file, then that file is considered post-processed.
Context Processors
- eventyay.base.context.contextprocessor(request)
- eventyay.control.context.contextprocessor(request)
Adds data to all template contexts
- eventyay.common.context_processors.add_events(request: HttpRequest)
- eventyay.common.context_processors.locale_context(request)
- eventyay.common.context_processors.messages(request)
- eventyay.common.context_processors.system_information(request)
Metrics & Monitoring
- class eventyay.base.metrics.Counter(name, helpstring, labelnames=None)
Bases:
MetricCounter Metric Object Counters can only be increased, they can neither be set to a specific value nor decreased.
- inc(amount=1, **kwargs)
Increments Counter by given amount for the labels specified in kwargs.
- class eventyay.base.metrics.Gauge(name, helpstring, labelnames=None)
Bases:
MetricGauge Metric Object Gauges can be set to a specific value, increased and decreased.
- dec(amount=1, **kwargs)
Decrements Gauge by given amount for the labels specified in kwargs.
- inc(amount=1, **kwargs)
Increments Gauge by given amount for the labels specified in kwargs.
- set(value=1, **kwargs)
Sets Gauge to a specific value for the labels specified in kwargs.
- class eventyay.base.metrics.Histogram(name, helpstring, labelnames=None, buckets=(0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, 30.0, inf))
Bases:
MetricHistogram Metric Object
- observe(amount, **kwargs)
Stores a value in the histogram for the labels specified in kwargs.
- class eventyay.base.metrics.Metric(name, helpstring, labelnames=None)
Bases:
objectBase Metrics Object
- eventyay.base.metrics.estimate_count_fast(type)
- eventyay.base.metrics.metric_values()
Produces the the values to be presented to the monitoring system
Timeline & Activity
- class eventyay.base.timeline.TimelineEvent(event, subevent, datetime, description, edit_url)
Bases:
tuple- datetime
Alias for field number 2
- description
Alias for field number 3
- edit_url
Alias for field number 4
- event
Alias for field number 0
- subevent
Alias for field number 1
- eventyay.base.timeline.timeline_for_event(event, subevent=None)