0001-custom_user-provide-more-generic-user-inactivity-not.patch
src/authentic2/templates/authentic2/unused_account_alert_body.html | ||
---|---|---|
1 |
{% load i18n humanize %}
|
|
1 |
{% load i18n %} |
|
2 | 2 |
<p>{% blocktrans %}Hi {{ user }},{% endblocktrans %}</p> |
3 | 3 | |
4 |
<p>{% blocktrans with last_login_date=user.last_login|naturaltime %}Your last logging was {{ last_login_date }}.{% endblocktrans %}</p>
|
|
4 |
<p>{% blocktrans %}Your account is inactive and is pending deletion.{% endblocktrans %}</p>
|
|
5 | 5 |
<p>{% blocktrans %}In order to keep your account, you must <a href="{{ login_url }}">log in</a> within {{ days_to_deletion }} days.{% endblocktrans %}</p> |
6 |
<p>{% trans "Otherwise, it will be deleted after this time." %}</p> |
|
6 |
<p>{% trans "Past this delay, it will be deleted." %}</p> |
src/authentic2/templates/authentic2/unused_account_alert_body.txt | ||
---|---|---|
1 |
{% load i18n humanize %}{% blocktrans %}Hi {{ user }},{% endblocktrans %}
|
|
1 |
{% load i18n %}{% blocktrans %}Hi {{ user }},{% endblocktrans %} |
|
2 | 2 | |
3 |
{% blocktrans with last_login_date=user.last_login|naturaltime %}Your last logging was {{ last_login_date }}.{% endblocktrans %}
|
|
3 |
{% blocktrans %}Your account is inactive and is pending deletion.{% endblocktrans %}
|
|
4 | 4 |
{% blocktrans %}In order to keep your account, you must log in within {{ days_to_deletion }} days.{% endblocktrans %} |
5 |
{% trans "Otherwise, it will be deleted after this time." %} |
|
5 |
{% trans "Past this delay, it will be deleted." %} |
src/authentic2/templates/authentic2/unused_account_alert_subject.txt | ||
---|---|---|
1 |
{% load i18n humanize %}{% blocktrans trimmed with last_login_date=user.last_login|naturaltime %}Alert: {{ user.get_full_name }} your last login was {{ last_login_date }}{% endblocktrans %} |
|
1 |
{% load i18n %}{% blocktrans trimmed %}Alert: {{ user }}, your account is inactive and is pending deletion{% endblocktrans %} |
src/authentic2/templates/authentic2/unused_account_delete_body.html | ||
---|---|---|
1 |
{% load i18n %} |
|
2 |
<p>{% blocktrans %}Hi {{ user }},{% endblocktrans %}</p> |
|
3 | ||
4 |
<p>{% blocktrans %}Your account was inactive, it has been deleted.{% endblocktrans %}</p> |
src/authentic2/templates/authentic2/unused_account_delete_body.txt | ||
---|---|---|
1 |
{% load i18n humanize %}{% blocktrans with last_login_date=user.last_login|naturaltime %}
|
|
2 |
Hi {{ user }}, |
|
1 |
{% load i18n %} |
|
2 |
{% blocktrans %}Hi {{ user }},{% endblocktrans %} |
|
3 | 3 | |
4 |
Since your last logging was {{ last_login_date }}, your account has been deleted.{% endblocktrans %} |
|
4 |
{% blocktrans %}Your account was inactive, it has been deleted.{% endblocktrans %} |
tests/test_commands.py | ||
---|---|---|
228 | 228 |
assert len(mailoutbox) == 1 |
229 | 229 | |
230 | 230 | |
231 |
@pytest.mark.parametrize( |
|
232 |
"deletion_delay,formatted", [(730, '2\xa0years'), (500, '1\xa0year'), (65, '2\xa0months')] |
|
233 |
) |
|
234 |
def test_clean_unused_account_human_duration_format(simple_user, mailoutbox, deletion_delay, formatted): |
|
235 |
simple_user.ou.clean_unused_accounts_alert = deletion_delay - 1 |
|
231 |
@pytest.mark.parametrize("deletion_delay", [730, 500, 65]) |
|
232 |
def test_clean_unused_account_displayed_message(simple_user, mailoutbox, deletion_delay): |
|
233 |
simple_user.ou.clean_unused_accounts_alert = deletion_delay - 30 |
|
236 | 234 |
simple_user.ou.clean_unused_accounts_deletion = deletion_delay |
237 | 235 |
simple_user.ou.save() |
238 |
simple_user.last_login = now() - datetime.timedelta(days=deletion_delay + 1)
|
|
236 |
simple_user.last_login = now() - datetime.timedelta(days=deletion_delay + 30)
|
|
239 | 237 |
simple_user.save() |
240 | 238 | |
241 | 239 |
# alert email |
242 | 240 |
call_command('clean-unused-accounts') |
243 | 241 |
mail = mailoutbox[0] |
244 |
assert formatted in mail.body |
|
245 |
assert formatted in mail.subject and not '\n' in mail.subject |
|
242 |
assert mail.subject == 'Alert: Jôhn Dôe, your account is inactive and is pending deletion' |
|
243 |
assert 'Jôhn Dôe' in mail.body |
|
244 |
assert 'In order to keep your account, you must log in within 30 days.' in mail.body |
|
246 | 245 | |
247 | 246 |
# deletion email |
248 |
simple_user.last_account_deletion_alert = now() - datetime.timedelta(days=2)
|
|
247 |
simple_user.last_account_deletion_alert = now() - datetime.timedelta(days=31)
|
|
249 | 248 |
simple_user.save() |
250 | 249 |
call_command('clean-unused-accounts') |
251 | 250 |
mail = mailoutbox[1] |
252 |
assert formatted in mail.body |
|
251 |
assert mail.subject == 'Notification: Jôhn Dôe, your account has been deleted' |
|
252 |
assert 'Jôhn Dôe' in mail.body |
|
253 |
assert 'Your account was inactive, it has been deleted.' in mail.body |
|
253 | 254 | |
254 | 255 | |
255 | 256 |
def test_clean_unused_account_login_url(simple_user, mailoutbox): |
256 |
- |