From 5cba47bced83e22058a9395a78115e0bbc332526 Mon Sep 17 00:00:00 2001 From: Ben van Basten Date: Fri, 26 Jan 2024 10:43:14 +0100 Subject: [PATCH] Invitation mail: Service email address is now interpolated, also added dutch version --- nens_auth_client/models.py | 19 +++++++++++++++---- .../nens_auth_client/invitation.html | 2 +- .../templates/nens_auth_client/invitation.txt | 2 +- .../nens_auth_client/uitnodiging.html | 5 +++++ .../nens_auth_client/uitnodiging.txt | 10 ++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 nens_auth_client/templates/nens_auth_client/uitnodiging.html create mode 100644 nens_auth_client/templates/nens_auth_client/uitnodiging.txt diff --git a/nens_auth_client/models.py b/nens_auth_client/models.py index 1ec126c..8512f33 100644 --- a/nens_auth_client/models.py +++ b/nens_auth_client/models.py @@ -233,9 +233,20 @@ 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"servicedesk@nelen-schuurmans.nl" + + 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 @@ -243,7 +254,7 @@ def send_email(self, request, context=None, send_email_options=None): message=text, html_message=html, recipient_list=[self.email], - **(send_email_options or {}) + **(send_email_options or {}), ) self.email_sent_at = timezone.now() diff --git a/nens_auth_client/templates/nens_auth_client/invitation.html b/nens_auth_client/templates/nens_auth_client/invitation.html index 9061836..0eca403 100644 --- a/nens_auth_client/templates/nens_auth_client/invitation.html +++ b/nens_auth_client/templates/nens_auth_client/invitation.html @@ -2,4 +2,4 @@

This is an invitation for a user account at {{ host }}.
Use the following link to accept:

{{ accept_url }}

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 servicedesk@nelen-schuurmans.nl.

\ No newline at end of file +

For questions, please contact {{ service_email }}.

\ No newline at end of file diff --git a/nens_auth_client/templates/nens_auth_client/invitation.txt b/nens_auth_client/templates/nens_auth_client/invitation.txt index 9e1405f..cbdc92f 100644 --- a/nens_auth_client/templates/nens_auth_client/invitation.txt +++ b/nens_auth_client/templates/nens_auth_client/invitation.txt @@ -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 servicedesk@nelen-schuurmans.nl. +For questions, please contact {{ service_email }}. diff --git a/nens_auth_client/templates/nens_auth_client/uitnodiging.html b/nens_auth_client/templates/nens_auth_client/uitnodiging.html new file mode 100644 index 0000000..7072c1c --- /dev/null +++ b/nens_auth_client/templates/nens_auth_client/uitnodiging.html @@ -0,0 +1,5 @@ +

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}}.

\ No newline at end of file diff --git a/nens_auth_client/templates/nens_auth_client/uitnodiging.txt b/nens_auth_client/templates/nens_auth_client/uitnodiging.txt new file mode 100644 index 0000000..4c4b591 --- /dev/null +++ b/nens_auth_client/templates/nens_auth_client/uitnodiging.txt @@ -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}}. \ No newline at end of file