From 2f3320b401b1e7da4e2167ab552f3b25d5009551 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 2 Apr 2020 18:02:36 +0200 Subject: [PATCH] templates: fixes in unused account emails (#41281) --- .../templates/authentic2/accounts_delete_request.html | 4 ++-- .../templates/authentic2/unused_account_alert_body.html | 7 +++++-- .../templates/authentic2/unused_account_alert_subject.txt | 7 ++++++- tests/test_commands.py | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/authentic2/templates/authentic2/accounts_delete_request.html b/src/authentic2/templates/authentic2/accounts_delete_request.html index 0ea3a835a..9efcd9bb8 100644 --- a/src/authentic2/templates/authentic2/accounts_delete_request.html +++ b/src/authentic2/templates/authentic2/accounts_delete_request.html @@ -16,12 +16,12 @@
{% csrf_token %}

- {% blocktrans %} + {% blocktrans trimmed %} Do you really want to delete your account? {% endblocktrans %}

- {% blocktrans %} + {% blocktrans trimmed %} A validation message will be sent to {{ email }}. You will have to visit the link in this email in order to complete the deletion process. {% endblocktrans %} diff --git a/src/authentic2/templates/authentic2/unused_account_alert_body.html b/src/authentic2/templates/authentic2/unused_account_alert_body.html index f3a978b95..65e52dc07 100644 --- a/src/authentic2/templates/authentic2/unused_account_alert_body.html +++ b/src/authentic2/templates/authentic2/unused_account_alert_body.html @@ -1,6 +1,9 @@ -{% load i18n %}{% autoescape off %}{% blocktrans %}Hi {{ user.get_full_name }}, +{% load i18n humanize %} +{% autoescape off %} +{% blocktrans with last_login_date=user.last_login|naturaltime %} +Hi {{ user.get_full_name }}, Your last logging was {{ last_login_date }}. -In order to keep your account, you must log in before {{ days_to_deletion }} days. +In order to keep your account, you must log in within {{ days_to_deletion }} days. Otherwise, it will be deleted after this time. {% endblocktrans %}{% endautoescape %} diff --git a/src/authentic2/templates/authentic2/unused_account_alert_subject.txt b/src/authentic2/templates/authentic2/unused_account_alert_subject.txt index 30b89996f..0649ed5d6 100644 --- a/src/authentic2/templates/authentic2/unused_account_alert_subject.txt +++ b/src/authentic2/templates/authentic2/unused_account_alert_subject.txt @@ -1 +1,6 @@ -{% load i18n %}{% autoescape off %}{% blocktrans %}Alert: {{ user }} you have not logged since {{ threshold }}{% endblocktrans %}{% endautoescape %} +{% load i18n humanize %} +{% autoescape off %} +{% blocktrans trimmed with last_login_date=user.last_login|naturaltime %} +Alert: {{ user.get_full_name }} your last login was {{ last_login_date }} +{% endblocktrans %} +{% endautoescape %} diff --git a/tests/test_commands.py b/tests/test_commands.py index a57230dd6..61800d26d 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -143,6 +143,7 @@ def test_clean_unused_account_human_duration_format(simple_user, mailoutbox, del management.call_command('clean-unused-accounts') mail = mailoutbox[0] assert formatted in mail.body + assert formatted in mail.subject and not '\n' in mail.subject # deletion email simple_user.last_account_deletion_alert = now() - datetime.timedelta(days=2) @@ -160,7 +161,7 @@ def test_clean_unused_account_login_url(simple_user, mailoutbox): simple_user.save() management.call_command('clean-unused-accounts') mail = mailoutbox[0] - assert 'href=http://localhost/login' in mail.message().as_string() + assert 'href="http://localhost/login/"' in mail.message().as_string() def test_cleanupauthentic(db):