♻️(backend) let callers override document email context defaults

We need this so mention notification emails can replace the default
share link with a link to the anchor of the mention.
This commit is contained in:
Mohamed El Amine BOUKERFA
2026-09-29 17:40:35 +02:00
committed by Manuel Raynaud
parent dc75d5493b
commit 4436b2a9f8
+14 -13
View File
@@ -1336,21 +1336,22 @@ class Document(MP_Node, BaseModel):
}
def send_email(self, subject, emails, context=None, language=None):
"""Generate and send email from a template."""
context = context or {}
"""Generate and send email from a template.
Keys passed in `context` take precedence over the default values.
"""
domain = settings.EMAIL_URL_APP or Site.objects.get_current().domain
language = language or get_language()
context.update(
{
"brandname": settings.EMAIL_BRAND_NAME,
"document": self,
"domain": domain,
"link": f"{domain}/docs/{self.id}/?utm_source=docssharelink&utm_campaign={self.id}",
"link_label": self.title or str(_("Untitled Document")),
"button_label": _("Open"),
"logo_img": settings.EMAIL_LOGO_IMG,
}
)
context = {
"brandname": settings.EMAIL_BRAND_NAME,
"document": self,
"domain": domain,
"link": f"{domain}/docs/{self.id}/?utm_source=docssharelink&utm_campaign={self.id}",
"link_label": self.title or str(_("Untitled Document")),
"button_label": _("Open"),
"logo_img": settings.EMAIL_LOGO_IMG,
**(context or {}),
}
with override(language):
msg_html = render_to_string("mail/html/template.html", context)