mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Allow template syntax in event text (Z#23140046) (#3815)
* remove duplicate context generation * allow text templates in frontpage_text * refactor: move placeholder functionality to separate file * fix wrong class name, code style * update year in license header * undo license header update * use new function name * render only the placeholders that are actually used in the message * refactoring * add str(...) call * Update doc/development/api/placeholder.rst Co-authored-by: Raphael Michel <michel@rami.io> * rename register_mail_placeholders to register_template_placeholders (deprecate old name) * isort * add signals to docs --------- Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
@@ -41,28 +41,16 @@ from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||
from django_scopes.forms import SafeModelMultipleChoiceField
|
||||
from i18nfield.forms import I18nFormField, I18nTextarea, I18nTextInput
|
||||
|
||||
from pretix.base.email import get_available_placeholders
|
||||
from pretix.base.forms import I18nModelForm, PlaceholderValidator
|
||||
from pretix.base.forms import I18nModelForm
|
||||
from pretix.base.forms.widgets import (
|
||||
SplitDateTimePickerWidget, TimePickerWidget, format_placeholders_help_text,
|
||||
SplitDateTimePickerWidget, TimePickerWidget,
|
||||
)
|
||||
from pretix.base.models import CheckinList, Item, Order, SubEvent
|
||||
from pretix.control.forms import CachedFileField, SplitDateTimeField
|
||||
from pretix.control.forms.widgets import Select2, Select2Multiple
|
||||
from pretix.plugins.sendmail.models import Rule
|
||||
|
||||
|
||||
class FormPlaceholderMixin:
|
||||
def _set_field_placeholders(self, fn, base_parameters):
|
||||
placeholders = get_available_placeholders(self.event, base_parameters)
|
||||
ht = format_placeholders_help_text(placeholders, self.event)
|
||||
if self.fields[fn].help_text:
|
||||
self.fields[fn].help_text += ' ' + str(ht)
|
||||
else:
|
||||
self.fields[fn].help_text = ht
|
||||
self.fields[fn].validators.append(
|
||||
PlaceholderValidator(['{%s}' % p for p in placeholders.keys()])
|
||||
)
|
||||
from pretix.base.services.placeholders import FormPlaceholderMixin # noqa
|
||||
|
||||
|
||||
class BaseMailForm(FormPlaceholderMixin, forms.Form):
|
||||
|
||||
Reference in New Issue
Block a user