mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Custom HTML email renderers and new email style (#991)
* Custom HTML email renderers * Move inline_css call * Small fixes * New HTML mail style for pretix * Thumbs * Inlinestyle for notifications * Documentation * Set line-height
This commit is contained in:
@@ -19,7 +19,6 @@ from django.utils.timezone import make_aware, now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from i18nfield.fields import I18nCharField, I18nTextField
|
||||
|
||||
from pretix.base.email import CustomSMTPBackend
|
||||
from pretix.base.models.base import LoggedModel
|
||||
from pretix.base.reldate import RelativeDateWrapper
|
||||
from pretix.base.validators import EventSlugBlacklistValidator
|
||||
@@ -327,6 +326,8 @@ class Event(EventMixin, LoggedModel):
|
||||
Returns an email server connection, either by using the system-wide connection
|
||||
or by returning a custom one based on the event's settings.
|
||||
"""
|
||||
from pretix.base.email import CustomSMTPBackend
|
||||
|
||||
if self.settings.smtp_use_custom or force_custom:
|
||||
return CustomSMTPBackend(host=self.settings.smtp_host,
|
||||
port=self.settings.smtp_port,
|
||||
@@ -479,6 +480,31 @@ class Event(EventMixin, LoggedModel):
|
||||
|
||||
return OrderedDict(sorted(providers.items(), key=lambda v: str(v[1].verbose_name)))
|
||||
|
||||
def get_html_mail_renderer(self):
|
||||
"""
|
||||
Returns the currently selected HTML email renderer
|
||||
"""
|
||||
return self.get_html_mail_renderers()[
|
||||
self.settings.mail_html_renderer
|
||||
]
|
||||
|
||||
def get_html_mail_renderers(self) -> dict:
|
||||
"""
|
||||
Returns a dictionary of initialized HTML email renderers mapped by their identifiers.
|
||||
"""
|
||||
from ..signals import register_html_mail_renderers
|
||||
|
||||
responses = register_html_mail_renderers.send(self)
|
||||
renderers = {}
|
||||
for receiver, response in responses:
|
||||
if not isinstance(response, list):
|
||||
response = [response]
|
||||
for p in response:
|
||||
pp = p(self)
|
||||
if pp.is_available:
|
||||
renderers[pp.identifier] = pp
|
||||
return renderers
|
||||
|
||||
def get_invoice_renderers(self) -> dict:
|
||||
"""
|
||||
Returns a dictionary of initialized invoice renderers mapped by their identifiers.
|
||||
|
||||
@@ -508,7 +508,7 @@ class Order(LoggedModel):
|
||||
with language(self.locale):
|
||||
recipient = self.email
|
||||
try:
|
||||
email_content = render_mail(template, context)[0]
|
||||
email_content = render_mail(template, context)
|
||||
mail(
|
||||
recipient, subject, template, context,
|
||||
self.event, self.locale, self, headers, sender,
|
||||
|
||||
Reference in New Issue
Block a user