Send registration emails as html

This commit is contained in:
Christian Cueni 2020-02-26 13:51:17 +01:00
parent 93798358ea
commit af818f5ee7
4 changed files with 45 additions and 9 deletions

View File

@ -355,12 +355,26 @@ WAGTAIL_SITE_NAME = 'skillbox'
GRAPHQL_QUERIES_DIR = os.path.join(BASE_DIR, '..', 'client', 'src', 'graphql', 'gql') GRAPHQL_QUERIES_DIR = os.path.join(BASE_DIR, '..', 'client', 'src', 'graphql', 'gql')
GRAPHQL_MUTATIONS_DIR = os.path.join(GRAPHQL_QUERIES_DIR, 'mutations') 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 <noreply@myskillbox.ch>' DEFAULT_FROM_EMAIL = 'myskillbox <noreply@myskillbox.ch>'
# 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_USER = os.environ.get("TASKBASE_USER")
TASKBASE_PASSWORD = os.environ.get("TASKBASE_PASSWORD") TASKBASE_PASSWORD = os.environ.get("TASKBASE_PASSWORD")
TASKBASE_SUPERUSER = os.environ.get("TASKBASE_SUPERUSER") TASKBASE_SUPERUSER = os.environ.get("TASKBASE_SUPERUSER")

View File

@ -1,15 +1,21 @@
{% load i18n %} {% load i18n %}
{% load core_tags %} {% load core_tags %}
{% autoescape off %} {% autoescape off %}
<p>
{% blocktrans %}Sie erhalten diese E-Mail, weil Ihr Passwort auf {{ site_name }} zurückgesetzt wurde.{% endblocktrans %}
</p>
{% blocktrans %}Du erhältst dieses E-Mail, weil dein Passwort auf {{ site_name }} zurückgesetzt wurde.{% endblocktrans %} <p>
{% trans "Bitte öffnen Sie folgende Seite, um Ihr neues Passwort einzugeben:" %} {% trans "Bitte öffnen Sie folgende Seite, um Ihr neues Passwort einzugeben:" %}
</p>
{% block reset_link %} {% block reset_link %}
<p>
<a href="{% reset_link 'password_reset_confirm' protocol domain token uid %}">{% reset_link 'password_reset_confirm' protocol domain token uid %}</a> <a href="{% reset_link 'password_reset_confirm' protocol domain token uid %}">{% reset_link 'password_reset_confirm' protocol domain token uid %}</a>
</p>
{% endblock %} {% endblock %}
<p>
{% trans "Ihr Benutzername lautet:" %} {{ user.get_username }} {% trans "Ihr Benutzername lautet:" %} {{ user.get_username }}
</p>
{% trans "Ihr Skillbox Team" %} {% trans "Ihr Skillbox Team" %}
{% endautoescape %} {% endautoescape %}

View File

@ -1,15 +1,26 @@
{% load i18n %} {% load i18n %}
{% load core_tags %} {% load core_tags %}
{% autoescape off %} {% autoescape off %}
<p>
{% blocktrans %}Sie erhalten diese E-Mail, um Ihr Passwort auf mySkillbox initial zu setzen.{% endblocktrans %} {% blocktrans %}Sie erhalten diese E-Mail, um Ihr Passwort auf mySkillbox initial zu setzen.{% endblocktrans %}
</p>
<p>
{% trans "Bitte öffnen Sie folgende Seite, um Ihr neues Passwort einzugeben:" %} {% trans "Bitte öffnen Sie folgende Seite, um Ihr neues Passwort einzugeben:" %}
</p>
<p>
{% block reset_link %} {% block reset_link %}
<a href="{% reset_link 'set_password_confirm' protocol domain token uid %}">{% reset_link 'set_password_confirm' protocol domain token uid %}</a> <a href="{% reset_link 'set_password_confirm' protocol domain token uid %}">{% reset_link 'set_password_confirm' protocol domain token uid %}</a>
</p>
{% endblock %} {% endblock %}
{% trans "Ihr Benutzername lautet:" %} {{ user.get_username }}
<p>
{% trans "Ihr Benutzername lautet:" %} {{ user.get_username }}
</p>
<p>
{% trans "Ihr mySkillbox Team" %} {% trans "Ihr mySkillbox Team" %}
</p>
{% endautoescape %} {% endautoescape %}

View File

@ -2,6 +2,7 @@ from django.conf import settings
from django.conf.urls import url, include from django.conf.urls import url, include
from django.conf.urls.static import static from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.contrib.auth.views import PasswordResetView
from django.urls import re_path, path from django.urls import re_path, path
from django.views.generic import RedirectView from django.views.generic import RedirectView
from wagtail.admin import urls as wagtailadmin_urls from wagtail.admin import urls as wagtailadmin_urls
@ -14,10 +15,14 @@ from core.views import LegacySetPasswordView, LegacySetPasswordDoneView, LegacyS
urlpatterns = [ urlpatterns = [
# django admin # django admin
url(r'^guru/', admin.site.urls), url(r'^guru/', admin.site.urls),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^statistics/', include('statistics.urls', namespace='statistics')), url(r'^statistics/', include('statistics.urls', namespace='statistics')),
# legacy - will be removed # 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 # set password
path('welcome/', LegacySetPasswordView.as_view(), name='set_password'), path('welcome/', LegacySetPasswordView.as_view(), name='set_password'),
path('set-password/done/', LegacySetPasswordDoneView.as_view(), name='set_password_done'), path('set-password/done/', LegacySetPasswordDoneView.as_view(), name='set_password_done'),