From 996d81966c7b6a6c260977506b0599dc5a67b52c Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells <10456740+cdubz@users.noreply.github.com> Date: Sat, 11 Feb 2023 09:02:23 -0800 Subject: [PATCH] Indicate user locked state and allow unlocking from users admin (#600) * Use custom template for account lock * Rename Baby Buddy base template tags * Add user unlock view * Add user unlock test --- babybuddy/settings/base.py | 4 ++ babybuddy/templates/babybuddy/base.html | 2 +- .../templates/babybuddy/login_qr_code.txt | 2 +- .../templates/babybuddy/nav-dropdown.html | 2 +- babybuddy/templates/babybuddy/paginator.html | 2 +- .../templates/babybuddy/user_add_device.html | 2 +- .../babybuddy/user_confirm_unlock.html | 21 ++++++++++ babybuddy/templates/babybuddy/user_form.html | 13 +++++- babybuddy/templates/babybuddy/user_list.html | 17 ++++---- .../babybuddy/user_settings_form.html | 2 +- babybuddy/templates/error/lockout.html | 8 ++++ .../{babybuddy_tags.py => babybuddy.py} | 13 ++++++ babybuddy/tests/tests_templatetags.py | 12 +++--- babybuddy/tests/tests_views.py | 16 ++++++++ babybuddy/urls.py | 1 + babybuddy/views.py | 40 ++++++++++++++++++- core/templates/core/timer_detail.html | 2 +- 17 files changed, 136 insertions(+), 23 deletions(-) create mode 100644 babybuddy/templates/babybuddy/user_confirm_unlock.html create mode 100644 babybuddy/templates/error/lockout.html rename babybuddy/templatetags/{babybuddy_tags.py => babybuddy.py} (86%) diff --git a/babybuddy/settings/base.py b/babybuddy/settings/base.py index 4c681db5..f8686ad9 100644 --- a/babybuddy/settings/base.py +++ b/babybuddy/settings/base.py @@ -337,6 +337,10 @@ AXES_COOLOFF_TIME = 1 AXES_FAILURE_LIMIT = 5 +AXES_LOCKOUT_TEMPLATE = "error/lockout.html" + +AXES_LOCKOUT_URL = "/login/lock" + # Session configuration # Used by RollingSessionMiddleware to determine how often to reset the session. # See https://docs.djangoproject.com/en/4.0/topics/http/sessions/ diff --git a/babybuddy/templates/babybuddy/base.html b/babybuddy/templates/babybuddy/base.html index 3593394f..40366d5c 100644 --- a/babybuddy/templates/babybuddy/base.html +++ b/babybuddy/templates/babybuddy/base.html @@ -1,4 +1,4 @@ -{% load babybuddy_tags i18n static %} +{% load babybuddy i18n static %} {% get_current_language as LANGUAGE_CODE %} {% get_current_locale as LOCALE %} {% get_current_timezone as TIMEZONE %} diff --git a/babybuddy/templates/babybuddy/login_qr_code.txt b/babybuddy/templates/babybuddy/login_qr_code.txt index 9b4182c9..fb63d885 100644 --- a/babybuddy/templates/babybuddy/login_qr_code.txt +++ b/babybuddy/templates/babybuddy/login_qr_code.txt @@ -1,4 +1,4 @@ -{% load i18n widget_tweaks babybuddy_tags qr_code %} +{% load i18n widget_tweaks babybuddy qr_code %} {% url 'babybuddy:root-router' as relative_root_url %} {% make_absolute_url relative_root_url as absolute_root_url %} BABYBUDDY-LOGIN:{"url":"{{ absolute_root_url }}","api_key":"{{ user.settings.api_key }}"} \ No newline at end of file diff --git a/babybuddy/templates/babybuddy/nav-dropdown.html b/babybuddy/templates/babybuddy/nav-dropdown.html index d577efae..e28c5ad3 100644 --- a/babybuddy/templates/babybuddy/nav-dropdown.html +++ b/babybuddy/templates/babybuddy/nav-dropdown.html @@ -1,5 +1,5 @@ {% extends 'babybuddy/base.html' %} -{% load babybuddy_tags i18n static timers %} +{% load babybuddy i18n static timers %} {% block nav %}