From 42ba4cc99c983002ca0424b511f464096b3ac7c3 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Thu, 6 Jun 2024 09:38:43 +0200 Subject: [PATCH] Put mail templates in a so-named directory --- alerts/tasks.py | 2 +- alerts/templates/{alerts => mails}/issue_alert.html | 0 alerts/templates/{alerts => mails}/issue_alert.txt | 0 alerts/views.py | 2 +- bugsink/urls.py | 6 +++--- teams/views.py | 6 +++--- users/tasks.py | 4 ++-- users/templates/{users => mails}/confirm_email.html | 0 users/templates/{users => mails}/confirm_email.txt | 0 users/templates/{users => mails}/reset_password_email.html | 0 users/templates/{users => mails}/reset_password_email.txt | 0 users/views.py | 2 +- 12 files changed, 11 insertions(+), 11 deletions(-) rename alerts/templates/{alerts => mails}/issue_alert.html (100%) rename alerts/templates/{alerts => mails}/issue_alert.txt (100%) rename users/templates/{users => mails}/confirm_email.html (100%) rename users/templates/{users => mails}/confirm_email.txt (100%) rename users/templates/{users => mails}/reset_password_email.html (100%) rename users/templates/{users => mails}/reset_password_email.txt (100%) diff --git a/alerts/tasks.py b/alerts/tasks.py index 7dea879..1fac78a 100644 --- a/alerts/tasks.py +++ b/alerts/tasks.py @@ -35,7 +35,7 @@ def _send_alert(issue_id, state_description, alert_article, alert_reason, **kwar for membership in _get_users_for_email_alert(issue): send_rendered_email( subject=truncatechars(f'"{issue.title()}" in "{issue.project.name}" ({state_description})', 100), - base_template_name="alerts/issue_alert", + base_template_name="mails/issue_alert", recipient_list=[membership.user.email], context={ "site_title": get_settings().SITE_TITLE, diff --git a/alerts/templates/alerts/issue_alert.html b/alerts/templates/mails/issue_alert.html similarity index 100% rename from alerts/templates/alerts/issue_alert.html rename to alerts/templates/mails/issue_alert.html diff --git a/alerts/templates/alerts/issue_alert.txt b/alerts/templates/mails/issue_alert.txt similarity index 100% rename from alerts/templates/alerts/issue_alert.txt rename to alerts/templates/mails/issue_alert.txt diff --git a/alerts/views.py b/alerts/views.py index 02aa04d..754a14e 100644 --- a/alerts/views.py +++ b/alerts/views.py @@ -16,4 +16,4 @@ DEBUG_CONTEXTS = { def debug_email(request, template_name): - return render(request, 'alerts/' + template_name + ".html", DEBUG_CONTEXTS[template_name]) + return render(request, 'mails/' + template_name + ".html", DEBUG_CONTEXTS[template_name]) diff --git a/bugsink/urls.py b/bugsink/urls.py index 3598757..117c453 100644 --- a/bugsink/urls.py +++ b/bugsink/urls.py @@ -45,9 +45,9 @@ urlpatterns = [ if settings.DEBUG: urlpatterns += [ - path('debug-alerts-email//', debug_alerts_email), - path('debug-users-email//', debug_users_email), - path('debug-teams-email//', debug_teams_email), + path('debug-alerts-email//', debug_alerts_email), + path('debug-users-email//', debug_users_email), + path('debug-teams-email//', debug_teams_email), path('trigger-error/', trigger_error), path("__debug__/", include("debug_toolbar.urls")), ] diff --git a/teams/views.py b/teams/views.py index 61c0bb4..883d4ae 100644 --- a/teams/views.py +++ b/teams/views.py @@ -292,13 +292,13 @@ def team_members_accept(request, team_pk): DEBUG_CONTEXTS = { - "mails/team_membership_invite_new_user": { + "team_membership_invite_new_user": { "site_title": get_settings().SITE_TITLE, "base_url": get_settings().BASE_URL + "/", "team_name": "Some team", "url": "http://example.com/confirm-email/1234567890abcdef", # nonsense to avoid circular import }, - "mails/team_membership_invite": { + "team_membership_invite": { "site_title": get_settings().SITE_TITLE, "base_url": get_settings().BASE_URL + "/", "team_name": "Some team", @@ -308,4 +308,4 @@ DEBUG_CONTEXTS = { def debug_email(request, template_name): - return render(request, template_name + ".html", DEBUG_CONTEXTS[template_name]) + return render(request, "mails/" + template_name + ".html", DEBUG_CONTEXTS[template_name]) diff --git a/users/tasks.py b/users/tasks.py index b876048..9a2cbd5 100644 --- a/users/tasks.py +++ b/users/tasks.py @@ -10,7 +10,7 @@ from bugsink.utils import send_rendered_email def send_confirm_email(email, token): send_rendered_email( subject="Confirm your email address", - base_template_name="users/confirm_email", + base_template_name="mails/confirm_email", recipient_list=[email], context={ "site_title": get_settings().SITE_TITLE, @@ -24,7 +24,7 @@ def send_confirm_email(email, token): def send_reset_email(email, token): send_rendered_email( subject="Reset your password", - base_template_name="users/reset_password_email", + base_template_name="mails/reset_password_email", recipient_list=[email], context={ "site_title": get_settings().SITE_TITLE, diff --git a/users/templates/users/confirm_email.html b/users/templates/mails/confirm_email.html similarity index 100% rename from users/templates/users/confirm_email.html rename to users/templates/mails/confirm_email.html diff --git a/users/templates/users/confirm_email.txt b/users/templates/mails/confirm_email.txt similarity index 100% rename from users/templates/users/confirm_email.txt rename to users/templates/mails/confirm_email.txt diff --git a/users/templates/users/reset_password_email.html b/users/templates/mails/reset_password_email.html similarity index 100% rename from users/templates/users/reset_password_email.html rename to users/templates/mails/reset_password_email.html diff --git a/users/templates/users/reset_password_email.txt b/users/templates/mails/reset_password_email.txt similarity index 100% rename from users/templates/users/reset_password_email.txt rename to users/templates/mails/reset_password_email.txt diff --git a/users/views.py b/users/views.py index 7e99866..bc34665 100644 --- a/users/views.py +++ b/users/views.py @@ -158,4 +158,4 @@ DEBUG_CONTEXTS = { def debug_email(request, template_name): - return render(request, 'users/' + template_name + ".html", DEBUG_CONTEXTS[template_name]) + return render(request, 'mails/' + template_name + ".html", DEBUG_CONTEXTS[template_name])