Skip to content

Commit

Permalink
Merge pull request #83 from nens/basten-customize_email
Browse files Browse the repository at this point in the history
Invitation mail: Service email address is now interpolated, also added dutch version
  • Loading branch information
benvanbasten-ns authored Jan 26, 2024
2 parents 4f1942e + 5cba47b commit cb9922d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
19 changes: 15 additions & 4 deletions nens_auth_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,28 @@ def send_email(self, request, context=None, send_email_options=None):
"host": request.get_host(),
**(context or {}),
}

text = render_to_string("nens_auth_client/invitation.txt", context=context)
html = render_to_string("nens_auth_client/invitation.html", context=context)
if context.get("service_email", None) is None:
context["service_email"] = r"[email protected]"

inv_lang = send_email_options.get("invitation_language", "en")
if inv_lang == "en":
text = render_to_string("nens_auth_client/invitation.txt", context=context)
html = render_to_string("nens_auth_client/invitation.html", context=context)
elif inv_lang == "nl":
text = render_to_string("nens_auth_client/uitnodiging.txt", context=context)
html = render_to_string(
"nens_auth_client/uitnodiging.html", context=context
)
else:
raise Exception(f"Unknown language code: {inv_lang}")

send_mail(
from_email=None, # uses DEFAULT_FROM_EMAIL setting
subject=settings.NENS_AUTH_INVITATION_EMAIL_SUBJECT,
message=text,
html_message=html,
recipient_list=[self.email],
**(send_email_options or {})
**(send_email_options or {}),
)

self.email_sent_at = timezone.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<p>This is an invitation for a user account at {{ host }}.<br />Use the following link to accept:</p>
<p><a href="{{ accept_url }}">{{ accept_url }}</a></p>
<p>The above link will first redirect to a page where you can sign in with a corporate ID or a Nelen &amp; Schuurmans account. If you do not have an account in any of the options listed, choose "Sign up".</p>
<p>For questions, please contact [email protected].</p>
<p>For questions, please contact {{ service_email }}.</p>
2 changes: 1 addition & 1 deletion nens_auth_client/templates/nens_auth_client/invitation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ The above link will first redirect to a page where you can sign in
with a corporate ID or a Nelen & Schuurmans account. If you do not have an
account in any of the options listed, choose "Sign up".

For questions, please contact [email protected].
For questions, please contact {{ service_email }}.
5 changes: 5 additions & 0 deletions nens_auth_client/templates/nens_auth_client/uitnodiging.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p>Beste gebruiker,</p>
<p>Dit is een uitnodigingsmail voor een gebruikersaccount voor {{ host }}.<br />Klik op onderstaande link om deze uitnodiging te accepteren:</p>
<p><a href="{{ accept_url }}">{{ accept_url }}</a></p>
<p>Deze link stuurt u door naar de inlogpagina waar u kunt inloggen met uw eigen corporate ID.</p>
<p>Mocht u vragen hebben, neem dan contact op met {{service_email}}.</p>
10 changes: 10 additions & 0 deletions nens_auth_client/templates/nens_auth_client/uitnodiging.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Beste gebruiker,

Dit is een uitnodigingsmail voor een gebruikersaccount voor {{ host }}.
Klik op onderstaande link om deze uitnodiging te accepteren:

{{ accept_url }}

Deze link stuurt u door naar de inlogpagina waar u kunt inloggen met uw eigen corporate ID.

Mocht u vragen hebben, neem dan contact op met {{service_email}}.

0 comments on commit cb9922d

Please sign in to comment.