mirror of
https://github.com/pretix/pretix.git
synced 2026-04-25 23:42:32 +00:00
* Data model draft * Refactor query and assignment usages of old permissions * Backend UI * API serializer * Big string replace * Docs, tests and fixes for teams api * Update docs for device auth * Eliminate old names * Make tests pass * Use new permissions, remove inconsistencies * Add test for translations * Show plugin permissions * Add permission for seating plans * Fix plugin activation * Fix failing test * Refactor to permission groups * Update doc/api/resources/devices.rst Co-authored-by: luelista <weller@rami.io> * Update doc/api/resources/events.rst Co-authored-by: luelista <weller@rami.io> * Update src/pretix/api/serializers/organizer.py Co-authored-by: luelista <weller@rami.io> * Fix typo * Fix python version compat * Replacement after rebase * Add proper permission handling for exports * Docs for exporters * Runtime linting of permission names * Fix typos * Show export page even without orders permission * More legacy compat * Do not strongly validate before plugins are loaded * Rebase migration * Add permission for outgoing mails * Review notes * Update doc/api/resources/teams.rst Co-authored-by: Richard Schreiber <schreiber@pretix.eu> * Clean up logic around exporters * Review and failures * Fix migration leading to forbidden combination * Handle permissions on event copying * Remove print-statements * Make test clearer * Review feedback * Add AnyPermissionOf * migration safety --------- Co-authored-by: luelista <weller@rami.io> Co-authored-by: Richard Schreiber <schreiber@pretix.eu>
104 lines
3.4 KiB
ReStructuredText
104 lines
3.4 KiB
ReStructuredText
.. highlight:: python
|
|
:linenothreshold: 5
|
|
|
|
Writing an exporter plugin
|
|
==========================
|
|
|
|
An Exporter is a method to export the product and order data in pretix for later use in another
|
|
program.
|
|
|
|
In this document, we will walk through the creation of an exporter output plugin step by step.
|
|
|
|
Please read :ref:`Creating a plugin <pluginsetup>` first, if you haven't already.
|
|
|
|
Exporter registration
|
|
---------------------
|
|
|
|
The exporter API does not make a lot of usage from signals, however, it does use a signal to get a list of
|
|
all available exporters. Your plugin should listen for this signal and return the subclass of
|
|
``pretix.base.exporter.BaseExporter``
|
|
that we'll provide in this plugin:
|
|
|
|
.. code-block:: python
|
|
|
|
from django.dispatch import receiver
|
|
|
|
from pretix.base.signals import register_data_exporters
|
|
|
|
|
|
@receiver(register_data_exporters, dispatch_uid="exporter_myexporter")
|
|
def register_data_exporter(sender, **kwargs):
|
|
from .exporter import MyExporter
|
|
return MyExporter
|
|
|
|
Some exporters might also prove to be useful, when provided on an organizer-level. In order to declare your
|
|
exporter as capable of providing exports spanning multiple events, your plugin should listen for this signal
|
|
and return the subclass of ``pretix.base.exporter.BaseExporter`` that we'll provide in this plugin:
|
|
|
|
.. code-block:: python
|
|
|
|
from django.dispatch import receiver
|
|
|
|
from pretix.base.signals import register_multievent_data_exporters
|
|
|
|
|
|
@receiver(register_multievent_data_exporters, dispatch_uid="multieventexporter_myexporter")
|
|
def register_multievent_data_exporter(sender, **kwargs):
|
|
from .exporter import MyExporter
|
|
return MyExporter
|
|
|
|
If your exporter supports both event-level and multi-event level exports, you will need to listen for both
|
|
signals.
|
|
|
|
The exporter class
|
|
------------------
|
|
|
|
.. class:: pretix.base.exporter.BaseExporter
|
|
|
|
The central object of each exporter is the subclass of ``BaseExporter``.
|
|
|
|
.. py:attribute:: BaseExporter.event
|
|
|
|
The default constructor sets this property to the event we are currently
|
|
working for. This will be ``None`` if the exporter is run for multiple
|
|
events.
|
|
|
|
.. py:attribute:: BaseExporter.events
|
|
|
|
The default constructor sets this property to the list of events to work
|
|
on, regardless of whether the exporter is called for one or multiple events.
|
|
|
|
.. autoattribute:: identifier
|
|
|
|
This is an abstract attribute, you **must** override this!
|
|
|
|
.. autoattribute:: verbose_name
|
|
|
|
This is an abstract attribute, you **must** override this!
|
|
|
|
.. autoattribute:: description
|
|
|
|
.. autoattribute:: category
|
|
|
|
.. autoattribute:: feature
|
|
|
|
.. autoattribute:: export_form_fields
|
|
|
|
.. autoattribute:: repeatable_read
|
|
|
|
.. automethod:: render
|
|
|
|
This is an abstract method, you **must** override this!
|
|
|
|
.. automethod:: available_for_user
|
|
|
|
.. automethod:: get_required_event_permission
|
|
|
|
On organizer level, by default exporters are expected to handle on a *set of events* and the system will automatically
|
|
add a form field that allows the selection of events, limited to events the user has correct permissions for. If this
|
|
does not fit your organizer, because it is not related to events, you should **also** inherit from the following class:
|
|
|
|
.. class:: pretix.base.exporter.OrganizerLevelExportMixin
|
|
|
|
.. automethod:: get_required_organizer_permission
|