Writing an exporter plugin¶
An Exporter is a method to export the submission or schedule data in pretalx 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 Creating a plugin first, if you haven’t already.
Exporter registration¶
The exporter API does not make a lot of usage from signals, but 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 pretalx.common.exporter.BaseExporter
that we’ll provide in this plugin:
1from django.dispatch import receiver
2
3from pretalx.common.signals import register_data_exporters
4
5
6@receiver(register_data_exporters, dispatch_uid="exporter_myexporter")
7def register_data_exporter(sender, **kwargs):
8 from .exporter import MyExporter
9 return MyExporter
The exporter class¶
- class pretalx.common.exporter.BaseExporter¶
The central object of each exporter is the subclass of
BaseExporter
.- BaseExporter.event¶
- BaseExporter.identifier¶
A short and unique identifier for this exporter.
This should only contain lower-case letters and in most cases will be the same as your package name.
This is an abstract attribute, you must override this!
- BaseExporter.verbose_name¶
A human-readable name for this exporter.
This should be short but self-explaining. Good examples include ‘JSON’ or ‘Microsoft Excel’.
This is an abstract attribute, you must override this!
- BaseExporter.public¶
Return True if the exported data should be publicly available once the event is public, False otherwise.
If you need additional data to decide, you can instead implement the
is_public(self, request, **kwargs)
method, which overrides this property.This is an abstract attribute, you must override this!
- BaseExporter.show_qrcode()¶
Return True if the link to the exporter should be shown as QR code, False (default) otherwise.
Override the get_qr_code method to override the QR code itself.
- BaseExporter.get_qrcode()¶
- BaseExporter.urls()¶
The base attribute of this class contains the relative URL where this exporter’s data will be found, e.g. /event/schedule/export/my- export.ext Use
exporter.urls.base.full()
for the complete URL, taking into account the configured event URL, or HTML export URL.
- BaseExporter.icon¶
Return either a fa- string or some other symbol to accompany the exporter in displays.
This is an abstract attribute, you must override this!
- BaseExporter.group¶
Return either ‘speaker’ or ‘submission’ to indicate on which organiser export page to list this export.
Invalid values default to ‘submission’, which is also where all schedule exports live.
If you are planning to write an exporter that exports to CSV, have a look at
the pretalx.common.exporters.CSVExporterMixin
class. If you inherit from
this class next to BaseExporter
, you can provide a filename
attribute
and a get_data
method, which should return the fieldnames
as an iterable,
and the data
as a list of dictionaries.
This has the advantage of sparing you CSV formatting issues and security
considerations, since the mixin takes care of all that.
Access¶
The export will now be available for organisers in the schedule related export
view. If you have set public = True
, it will also show up in the drop down
in the event agenda.