From af818f5ee75f44db82d93b87a2e7fc4c8e7999af Mon Sep 17 00:00:00 2001 From: Christian Cueni Date: Wed, 26 Feb 2020 13:51:17 +0100 Subject: [PATCH] Send registration emails as html --- server/core/settings.py | 20 ++++++++++++++++--- .../registration/password_reset_email.html | 12 ++++++++--- .../registration_set_password_email.html | 15 ++++++++++++-- server/core/urls.py | 7 ++++++- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/server/core/settings.py b/server/core/settings.py index 6d20ef89..2763936f 100644 --- a/server/core/settings.py +++ b/server/core/settings.py @@ -355,12 +355,26 @@ WAGTAIL_SITE_NAME = 'skillbox' GRAPHQL_QUERIES_DIR = os.path.join(BASE_DIR, '..', 'client', 'src', 'graphql', 'gql') GRAPHQL_MUTATIONS_DIR = os.path.join(GRAPHQL_QUERIES_DIR, 'mutations') -EMAIL_BACKEND = 'sendgrid_backend.SendgridBackend' +# Sendgrid Config + +# EMAIL_BACKEND = 'sendgrid_backend.SendgridBackend' +# +# SENDGRID_API_KEY = os.environ.get("SENDGRID_API_KEY") +# SENDGRID_SANDBOX_MODE_IN_DEBUG = False -SENDGRID_API_KEY = os.environ.get("SENDGRID_API_KEY") -SENDGRID_SANDBOX_MODE_IN_DEBUG = False DEFAULT_FROM_EMAIL = 'myskillbox ' +# Metanet Config +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' + +EMAIL_HOST = os.environ.get("EMAIL_HOST") +EMAIL_PORT = os.environ.get("EMAIL_PORT") +EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD") +EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER") +EMAIL_USE_TLS = True +EMAIL_USE_SSL = False + + TASKBASE_USER = os.environ.get("TASKBASE_USER") TASKBASE_PASSWORD = os.environ.get("TASKBASE_PASSWORD") TASKBASE_SUPERUSER = os.environ.get("TASKBASE_SUPERUSER") diff --git a/server/core/templates/registration/password_reset_email.html b/server/core/templates/registration/password_reset_email.html index 41f235c8..a8204a5d 100644 --- a/server/core/templates/registration/password_reset_email.html +++ b/server/core/templates/registration/password_reset_email.html @@ -1,15 +1,21 @@ {% load i18n %} {% load core_tags %} {% autoescape off %} +

+{% blocktrans %}Sie erhalten diese E-Mail, weil Ihr Passwort auf {{ site_name }} zurückgesetzt wurde.{% endblocktrans %} +

-{% blocktrans %}Du erhältst dieses E-Mail, weil dein Passwort auf {{ site_name }} zurückgesetzt wurde.{% endblocktrans %} - +

{% trans "Bitte öffnen Sie folgende Seite, um Ihr neues Passwort einzugeben:" %} +

{% block reset_link %} +

{% reset_link 'password_reset_confirm' protocol domain token uid %} +

{% endblock %} +

{% trans "Ihr Benutzername lautet:" %} {{ user.get_username }} - +

{% trans "Ihr Skillbox Team" %} {% endautoescape %} diff --git a/server/core/templates/registration/registration_set_password_email.html b/server/core/templates/registration/registration_set_password_email.html index f848abd9..c40669be 100644 --- a/server/core/templates/registration/registration_set_password_email.html +++ b/server/core/templates/registration/registration_set_password_email.html @@ -1,15 +1,26 @@ {% load i18n %} {% load core_tags %} {% autoescape off %} - +

{% blocktrans %}Sie erhalten diese E-Mail, um Ihr Passwort auf mySkillbox initial zu setzen.{% endblocktrans %} +

+

{% trans "Bitte öffnen Sie folgende Seite, um Ihr neues Passwort einzugeben:" %} +

+ +

{% block reset_link %} {% reset_link 'set_password_confirm' protocol domain token uid %} +

{% endblock %} -{% trans "Ihr Benutzername lautet:" %} {{ user.get_username }} +

+{% trans "Ihr Benutzername lautet:" %} {{ user.get_username }} +

+ +

{% trans "Ihr mySkillbox Team" %} +

{% endautoescape %} diff --git a/server/core/urls.py b/server/core/urls.py index ef247798..fb93d8d2 100644 --- a/server/core/urls.py +++ b/server/core/urls.py @@ -2,6 +2,7 @@ from django.conf import settings from django.conf.urls import url, include from django.conf.urls.static import static from django.contrib import admin +from django.contrib.auth.views import PasswordResetView from django.urls import re_path, path from django.views.generic import RedirectView from wagtail.admin import urls as wagtailadmin_urls @@ -14,10 +15,14 @@ from core.views import LegacySetPasswordView, LegacySetPasswordDoneView, LegacyS urlpatterns = [ # django admin url(r'^guru/', admin.site.urls), - url(r'^accounts/', include('django.contrib.auth.urls')), url(r'^statistics/', include('statistics.urls', namespace='statistics')), # legacy - will be removed + # forgot password + path('accounts/password_reset/', + PasswordResetView.as_view(html_email_template_name='registration/password_reset_email.html')), + path(r'accounts/', include('django.contrib.auth.urls')), + # set password path('welcome/', LegacySetPasswordView.as_view(), name='set_password'), path('set-password/done/', LegacySetPasswordDoneView.as_view(), name='set_password_done'),