Merge branch 'develop' into 'master'
Use html templates for kaehmy emails. No translations for now. See merge request sahkoinsinoorikilta/vtmk/web2.0-backend!84
This commit is contained in:
+10
-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.views.decorators.csrf import ensure_csrf_cookie
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from sikweb.settings import URL
|
from sikweb.settings import URL
|
||||||
@@ -64,14 +65,15 @@ def comment(request, *args, **kwargs):
|
|||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
comment = form.save()
|
comment = form.save()
|
||||||
name = comment.name
|
name = comment.name
|
||||||
|
url = f"https://{URL}/kaehmy"
|
||||||
|
|
||||||
to_email = comment.parent.email
|
to_email = comment.parent.email
|
||||||
subject = "Kaehmyysi tai kommenttiisi on vastattu!"
|
subject = "Kaehmyysi tai kommenttiisi on vastattu!"
|
||||||
email_body = (
|
message = render_to_string(
|
||||||
f"{name.capitalize()} on vastannut kaehmyhakemukseesi tai kommenttiisi kaehmypalvelussa.\r\n\r\n"
|
"kaehmy/email_comment.html", {"name": name, "url": url}
|
||||||
"Käy lukemassa viesti osoitteessa https://{URL}/kaehmy"
|
|
||||||
)
|
)
|
||||||
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}>")
|
logging.debug(f"Sent kaehmy comment email to recipient <{to_email}>")
|
||||||
|
|
||||||
return redirect("/kaehmy")
|
return redirect("/kaehmy")
|
||||||
@@ -129,16 +131,14 @@ def submit(request, *args, **kwargs):
|
|||||||
|
|
||||||
url = f"https://{URL}/kaehmy"
|
url = f"https://{URL}/kaehmy"
|
||||||
name = form.cleaned_data.get("name", "Anonymous")
|
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", "")
|
to_email = form.cleaned_data.get("email", "")
|
||||||
subject = "Arwokas kirjattu kirje mahdolliselle tulewalle kiltahenkilölle"
|
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}>")
|
logging.debug(f"Sent kaehmy email to recipient <{to_email}>")
|
||||||
|
|
||||||
processHooks(message=f"Uusi New kaehmy! {name} -> {url}", eventType="kaehmy")
|
processHooks(message=f"Uusi New kaehmy! {name} -> {url}", eventType="kaehmy")
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Hei!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{{ name }} on vastannut kaehmyhakemukseesi tai kommenttiisi kaehmypalvelussa.
|
||||||
|
Käy lukemassa viesti
|
||||||
|
<a href={{ url }}>täältä.</a>
|
||||||
|
</p>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Moikka {{ name }}!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Hienoa, että kilta kiinnostaa! Kaehmysi on vastaanotettu.
|
||||||
|
Mahdollisista kommenteista tulee ilmoitus sähköpostitse.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Käy katsomassa kaehmytilanne
|
||||||
|
<a href={{ url }}>täältä.</a>
|
||||||
|
</p>
|
||||||
Reference in New Issue
Block a user