diff --git a/core/templatetags/__init__.py b/core/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/core/templatetags/mail_tags.py b/core/templatetags/mail_tags.py
new file mode 100644
index 0000000..60cbc8b
--- /dev/null
+++ b/core/templatetags/mail_tags.py
@@ -0,0 +1,25 @@
+from django.template import Library, Template
+
+register = Library()
+
+
+@register.inclusion_tag("emails/_body_content.html", takes_context=True)
+def email_body_content(context, content):
+ template = Template(content)
+ return {"content": template.render(context)}
+
+
+@register.inclusion_tag("emails/_button.html", takes_context=True)
+def email_button(context, button_text, button_link):
+ text_template = Template(button_text)
+ link_template = Template(button_link)
+ return {
+ "button_text": text_template.render(context),
+ "button_link": link_template.render(context),
+ }
+
+
+@register.inclusion_tag("emails/_footer.html", takes_context=True)
+def email_footer(context, content):
+ template = Template(content)
+ return {"content": template.render(context)}
diff --git a/templates/emails/_body_content.html b/templates/emails/_body_content.html
new file mode 100644
index 0000000..c41af1b
--- /dev/null
+++ b/templates/emails/_body_content.html
@@ -0,0 +1,3 @@
+{% autoescape off %}
+
+
+ |
+
+
+
+
+
+ {% block body %}
+
+
+
+
+
+
+ {% block body_greeting %}
+ {% endblock body_greeting %}
+ {% block body_content %}
+ {% endblock body_content %}
+ {% block body_button %}
+ {% endblock body_button %}
+ {% block body_signature %}
+ {% endblock body_signature %}
+ |
+
+
+ |
+
+ {% endblock body %}
+
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+{% endautoescape %}
diff --git a/templates/emails/password_reset.html b/templates/emails/password_reset.html
new file mode 100644
index 0000000..bb02565
--- /dev/null
+++ b/templates/emails/password_reset.html
@@ -0,0 +1,27 @@
+{% extends "emails/base.html" %}
+{% load mail_tags %}
+{% autoescape off %}
+{% block title %}{{settings.MAIN_DOMAIN}} - Password Reset Requested{% endblock title %}
+{% block subtitle %}{{settings.MAIN_DOMAIN}} - Password Reset Requested{% endblock subtitle %}
+
+{% block body_greeting %}
+ {% email_body_content "Hi there," %}
+{% endblock body_greeting %}
+
+{% block body_content %}
+ {% email_body_content "A password reset was requested for your account ({{reset.user.email}}) at {{Config.system.site_name}} (https://{{settings.MAIN_DOMAIN}})." %}
+ {% email_body_content "To reset your password, go to this link:" %}
+{% endblock body_content %}
+
+{% block body_button %}
+ {% email_button button_text="Reset Password" button_link="https://{{settings.MAIN_DOMAIN}}/auth/reset/{{reset.token}}/" %}
+{% endblock body_button %}
+
+{% block body_signature %}
+ {% email_body_content "Thanks, Admins @{{settings.MAIN_DOMAIN}}" %}
+{% endblock body_signature %}
+
+{% block extra_footer %}
+ {% email_footer "If this was not you, then please ignore this message - your password will not be reset if this link is not visited." %}
+{% endblock extra_footer %}
+{% endautoescape %}
diff --git a/users/models/password_reset.py b/users/models/password_reset.py
index c300d23..90c61fd 100644
--- a/users/models/password_reset.py
+++ b/users/models/password_reset.py
@@ -34,6 +34,14 @@ class PasswordResetStates(StateGraph):
"settings": settings,
},
),
+ html_message=render_to_string(
+ "emails/account_new.html",
+ {
+ "reset": reset,
+ "config": Config.system,
+ "settings": settings,
+ },
+ ),
from_email=settings.SERVER_EMAIL,
recipient_list=[reset.user.email],
)
@@ -48,6 +56,14 @@ class PasswordResetStates(StateGraph):
"settings": settings,
},
),
+ html_message=render_to_string(
+ "emails/password_reset.html",
+ {
+ "reset": reset,
+ "config": Config.system,
+ "settings": settings,
+ },
+ ),
from_email=settings.SERVER_EMAIL,
recipient_list=[reset.user.email],
)