Add short method to email marketing template context
This allows dynamic URL to be shorten and tracked. Closes #12785
This commit is contained in:
@@ -9,6 +9,7 @@ from email.header import Header
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.utils import formataddr, getaddresses
|
||||
from functools import partial
|
||||
from urllib.parse import (
|
||||
parse_qsl, quote, urlencode, urljoin, urlsplit, urlunsplit)
|
||||
|
||||
@@ -593,6 +594,7 @@ class Activity(ModelSQL, ModelView):
|
||||
yield kind, data, pos
|
||||
|
||||
context = self.email_context(record)
|
||||
context['short'] = partial(short, event='on_email_clicked')
|
||||
title = (TextTemplate(translated.email_title)
|
||||
.generate(**context)
|
||||
.render())
|
||||
|
||||
@@ -7,7 +7,7 @@ from email.header import Header
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.utils import formataddr, getaddresses
|
||||
from functools import lru_cache
|
||||
from functools import lru_cache, partial
|
||||
from urllib.parse import (
|
||||
parse_qs, parse_qsl, urlencode, urljoin, urlsplit, urlunsplit)
|
||||
|
||||
@@ -508,7 +508,9 @@ class Message(Workflow, ModelSQL, ModelView):
|
||||
template = MarkupTemplate(message.content)
|
||||
for email in (emails or message.list_.emails):
|
||||
content = (template
|
||||
.generate(email=email)
|
||||
.generate(
|
||||
email=email,
|
||||
short=partial(short, record=message))
|
||||
.filter(convert_href(message))
|
||||
.render())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user