Use html templates for kaehmy emails. No translations for now.
This commit is contained in:
+12
-10
@@ -4,6 +4,7 @@ from django.views.decorators.http import require_http_methods
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
import logging
|
||||
from sikweb.settings import URL
|
||||
@@ -64,14 +65,16 @@ def comment(request, *args, **kwargs):
|
||||
if form.is_valid():
|
||||
comment = form.save()
|
||||
name = comment.name
|
||||
url = f"https://{URL}/kaehmy"
|
||||
|
||||
to_email = comment.parent.email
|
||||
subject = "Kaehmyysi tai kommenttiisi on vastattu!"
|
||||
email_body = (
|
||||
f"{name.capitalize()} on vastannut kaehmyhakemukseesi tai kommenttiisi kaehmypalvelussa.\r\n\r\n"
|
||||
"Käy lukemassa viesti osoitteessa https://{URL}/kaehmy"
|
||||
message = render_to_string(
|
||||
"kaehmy/email_comment.html",
|
||||
{ "name": name, "url": url }
|
||||
)
|
||||
send_email(to=to_email, subject=subject, body=email_body)
|
||||
|
||||
send_email(to=to_email, subject=subject, body=message, html=True)
|
||||
logging.debug(f"Sent kaehmy comment email to recipient <{to_email}>")
|
||||
|
||||
return redirect("/kaehmy")
|
||||
@@ -129,16 +132,15 @@ def submit(request, *args, **kwargs):
|
||||
|
||||
url = f"https://{URL}/kaehmy"
|
||||
name = form.cleaned_data.get("name", "Anonymous")
|
||||
email_body = (
|
||||
f"Moikka {name}!\r\n\r\nHienoa, että kilta kiinnostaa! Kaehmysi on vastaanotettu.\r\n"
|
||||
"Mahdollisista kommenteista tulee ilmoitus sähköpostitse.\r\n\r\n"
|
||||
"Käy katsomassa kaehmytilanne osoitteessa {url}"
|
||||
)
|
||||
|
||||
to_email = form.cleaned_data.get("email", "")
|
||||
subject = "Arwokas kirjattu kirje mahdolliselle tulewalle kiltahenkilölle"
|
||||
message = render_to_string(
|
||||
"kaehmy/email_kaehmy.html",
|
||||
{ "name": name, "url": url }
|
||||
)
|
||||
|
||||
send_email(to_email, subject, email_body)
|
||||
send_email(to=to_email, subject=subject, body=message, html=True)
|
||||
logging.debug(f"Sent kaehmy email to recipient <{to_email}>")
|
||||
|
||||
processHooks(message=f"Uusi New kaehmy! {name} -> {url}", eventType="kaehmy")
|
||||
|
||||
Reference in New Issue
Block a user