mirror of
https://github.com/pretix/pretix.git
synced 2026-05-11 16:13:59 +00:00
Remove duplicate rendering of plain content without variables
This commit is contained in:
@@ -254,20 +254,20 @@ def mail(email: Union[str, Sequence[str]], subject: str, template: Union[str, La
|
|||||||
if event and attach_tickets and not event.settings.mail_attach_tickets:
|
if event and attach_tickets and not event.settings.mail_attach_tickets:
|
||||||
attach_tickets = False
|
attach_tickets = False
|
||||||
|
|
||||||
with language(locale):
|
with language(locale), override(timezone):
|
||||||
if isinstance(context, dict) and order:
|
if isinstance(context, dict) and order:
|
||||||
_autoextend_context(context, order)
|
_autoextend_context(context, order)
|
||||||
|
|
||||||
# Build raw content
|
# Build raw content
|
||||||
body_plain = render_mail(template, context, placeholder_mode=None)
|
content_plain = render_mail(template, context, placeholder_mode=None)
|
||||||
if settings_holder:
|
if settings_holder:
|
||||||
signature = str(settings_holder.settings.get('mail_text_signature'))
|
signature = str(settings_holder.settings.get('mail_text_signature'))
|
||||||
else:
|
else:
|
||||||
signature = ""
|
signature = ""
|
||||||
|
|
||||||
# Build full plain-text body
|
# Build full plain-text body
|
||||||
|
body_plain = format_map(content_plain, context, mode=SafeFormatter.MODE_RICH_TO_PLAIN)
|
||||||
body_plain = _wrap_plain_body(body_plain, signature, event, order, position, no_order_links)
|
body_plain = _wrap_plain_body(body_plain, signature, event, order, position, no_order_links)
|
||||||
body_plain = format_map(body_plain, context, mode=SafeFormatter.MODE_RICH_TO_PLAIN)
|
|
||||||
|
|
||||||
# Build subject
|
# Build subject
|
||||||
if not isinstance(subject, FormattedString):
|
if not isinstance(subject, FormattedString):
|
||||||
@@ -291,8 +291,6 @@ def mail(email: Union[str, Sequence[str]], subject: str, template: Union[str, La
|
|||||||
else:
|
else:
|
||||||
renderer = ClassicMailRenderer(None, organizer)
|
renderer = ClassicMailRenderer(None, organizer)
|
||||||
|
|
||||||
with override(timezone):
|
|
||||||
content_plain = render_mail(template, context, placeholder_mode=None)
|
|
||||||
try:
|
try:
|
||||||
if 'context' in inspect.signature(renderer.render).parameters:
|
if 'context' in inspect.signature(renderer.render).parameters:
|
||||||
body_html = renderer.render(content_plain, signature, raw_subject, order, position, context)
|
body_html = renderer.render(content_plain, signature, raw_subject, order, position, context)
|
||||||
@@ -941,7 +939,7 @@ def _wrap_plain_body(content_plain, signature, event, order, position, no_order_
|
|||||||
body_plain += "\r\n\r\n-- \r\n"
|
body_plain += "\r\n\r\n-- \r\n"
|
||||||
|
|
||||||
if signature:
|
if signature:
|
||||||
signature = signature.format(event=event.name if event else '')
|
signature = format_map(signature, {"event": event.name if event else ''})
|
||||||
body_plain += signature
|
body_plain += signature
|
||||||
body_plain += "\r\n\r\n-- \r\n"
|
body_plain += "\r\n\r\n-- \r\n"
|
||||||
|
|
||||||
@@ -953,7 +951,7 @@ def _wrap_plain_body(content_plain, signature, event, order, position, no_order_
|
|||||||
body_plain += _(
|
body_plain += _(
|
||||||
"You can view your order details at the following URL:\n{orderurl}."
|
"You can view your order details at the following URL:\n{orderurl}."
|
||||||
).replace("\n", "\r\n").format(
|
).replace("\n", "\r\n").format(
|
||||||
event=event.name, orderurl=build_absolute_uri(
|
orderurl=build_absolute_uri(
|
||||||
order.event, 'presale:event.order.position', kwargs={
|
order.event, 'presale:event.order.position', kwargs={
|
||||||
'order': order.code,
|
'order': order.code,
|
||||||
'secret': position.web_secret,
|
'secret': position.web_secret,
|
||||||
|
|||||||
Reference in New Issue
Block a user