mirror of
https://github.com/pretix/pretix.git
synced 2025-12-31 18:22:26 +00:00
Document setting storage and mail sending
This commit is contained in:
7
doc/development/implementation/email.rst
Normal file
7
doc/development/implementation/email.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
Sending Email
|
||||
=============
|
||||
|
||||
As pretix allows event organizers to configure how they want to sent emails to their users in multiple ways.
|
||||
Therefore, all emails should be sent throught the following function:
|
||||
|
||||
.. autofunction:: pretix.base.services.mail.mail
|
||||
@@ -11,6 +11,8 @@ Contents:
|
||||
:maxdepth: 2
|
||||
|
||||
models
|
||||
background
|
||||
urlconfig
|
||||
i18n
|
||||
settings
|
||||
background
|
||||
email
|
||||
|
||||
52
doc/development/implementation/settings.rst
Normal file
52
doc/development/implementation/settings.rst
Normal file
@@ -0,0 +1,52 @@
|
||||
Settings storage
|
||||
================
|
||||
|
||||
pretix is highly configurable and therefore needs to store a lot of per-event and per-organizer settings.
|
||||
Those settings are stored in the database and accessed through a ``SettingsProxy`` instance. You can obtain
|
||||
such an instance from any event or organizer model instance by just accessing ``event.settings``.
|
||||
|
||||
Any setting consists of a key and a value. By default, all settings are strings, but the settings system
|
||||
includes serializers for serializing the following types:
|
||||
|
||||
* Built-in types: ``int``, ``float``, ``decimal.Decimal``, ``dict``, ``list``, ``bool``
|
||||
* ``datetime.date``, ``datetime.datetime``, ``datetime.time``
|
||||
* ``LazyI18nString``
|
||||
* References to Django ``File`` objects that are already stored in a storage backend
|
||||
* References to model instances
|
||||
|
||||
In code, we recommend to always use the ``.get()`` method on the settings object to access a value, but for
|
||||
convenience in templates you can also access settings values at ``settings[name]`` and ``settings.name``.
|
||||
|
||||
.. autoclass:: pretix.base.settings.SettingsProxy
|
||||
:members: get, set, delete, freeze
|
||||
|
||||
To avoid naming conflicts, plugins are requested to prefix all settings they use with the name of the plugin
|
||||
or something unique, e.g. ``payment.paypal.api_key``. To reduce redundant typing of this prefix, we provide
|
||||
another helper class:
|
||||
|
||||
.. autoclass:: pretix.base.settings.SettingsSandbox
|
||||
|
||||
When implementing e.g. a payment or export provider, you do not event need to create this sandbox yourself,
|
||||
you will just be passed a sandbox object with a prefix generated from your provider name.
|
||||
|
||||
Forms
|
||||
-----
|
||||
|
||||
We also provide a base class for forms that allow the modification of settings:
|
||||
|
||||
.. autoclass:: pretix.base.forms.SettingsForm
|
||||
:members: save
|
||||
|
||||
You can simply use it like this::
|
||||
|
||||
class EventSettingsForm(SettingsForm):
|
||||
show_date_to = forms.BooleanField(
|
||||
label=_("Show event end date"),
|
||||
help_text=_("If disabled, only event's start date will be displayed to the public."),
|
||||
required=False
|
||||
)
|
||||
payment_term_days = forms.IntegerField(
|
||||
label=_('Payment term in days'),
|
||||
help_text=_("The number of days after placing an order the user has to pay to "
|
||||
"preserve his reservation."),
|
||||
)
|
||||
Reference in New Issue
Block a user