mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54: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:
@@ -58,6 +58,7 @@ from pretix.base.models import (
|
||||
CartPosition, Event, ItemVariation, Quota, SubEvent, Voucher,
|
||||
)
|
||||
from pretix.base.services.cart import error_messages
|
||||
from pretix.base.services.placeholders import PlaceholderContext
|
||||
from pretix.base.settings import GlobalSettingsObject
|
||||
from pretix.base.templatetags.rich_text import rich_text
|
||||
from pretix.helpers.daterange import daterange
|
||||
@@ -699,11 +700,13 @@ class WidgetAPIProductList(EventListMixin, View):
|
||||
|
||||
ev = self.subevent or request.event
|
||||
data['name'] = str(ev.name)
|
||||
|
||||
templating_context = PlaceholderContext(event_or_subevent=ev, event=request.event)
|
||||
if self.subevent:
|
||||
data['frontpage_text'] = str(rich_text(self.subevent.frontpage_text, safelinks=False))
|
||||
data['frontpage_text'] = str(rich_text(templating_context.format(str(self.subevent.frontpage_text)), safelinks=False))
|
||||
data['location'] = str(rich_text(self.subevent.location, safelinks=False))
|
||||
else:
|
||||
data['frontpage_text'] = str(rich_text(request.event.settings.frontpage_text, safelinks=False))
|
||||
data['frontpage_text'] = str(rich_text(templating_context.format(str(request.event.settings.frontpage_text)), safelinks=False))
|
||||
data['location'] = str(rich_text(request.event.location, safelinks=False))
|
||||
data['date_range'] = self._get_date_range(ev, request.event)
|
||||
fail = False
|
||||
|
||||
Reference in New Issue
Block a user