From e4c9a8302dfb29c5ea3d6baa11190090dc2c3fe6 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Tue, 26 Jul 2022 17:28:39 +0200 Subject: [PATCH 1/4] authenticators: add login form customization fields (#51363) --- .../migrations/0004_auto_20220726_1708.py | 28 +++++++++++++++++++ src/authentic2/apps/authenticators/models.py | 9 ++++++ src/authentic2_auth_fc/forms.py | 2 +- tests/test_manager_authenticators.py | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/authentic2/apps/authenticators/migrations/0004_auto_20220726_1708.py diff --git a/src/authentic2/apps/authenticators/migrations/0004_auto_20220726_1708.py b/src/authentic2/apps/authenticators/migrations/0004_auto_20220726_1708.py new file mode 100644 index 00000000..ca581f84 --- /dev/null +++ b/src/authentic2/apps/authenticators/migrations/0004_auto_20220726_1708.py @@ -0,0 +1,28 @@ +# Generated by Django 2.2.26 on 2022-07-26 15:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('authenticators', '0003_auto_20220413_1504'), + ] + + operations = [ + migrations.AddField( + model_name='baseauthenticator', + name='button_description', + field=models.CharField( + blank=True, + help_text='Description will be shown on login page above login button (unless already set by theme).', + max_length=256, + verbose_name='Login button description', + ), + ), + migrations.AddField( + model_name='baseauthenticator', + name='button_label', + field=models.CharField(default='Login', max_length=64, verbose_name='Login button label'), + ), + ] diff --git a/src/authentic2/apps/authenticators/models.py b/src/authentic2/apps/authenticators/models.py index 9195dfc9..207f44ac 100644 --- a/src/authentic2/apps/authenticators/models.py +++ b/src/authentic2/apps/authenticators/models.py @@ -58,6 +58,15 @@ class BaseAuthenticator(models.Model): 'service_ou_slug, service_slug, remote_addr, login_hint and headers.' ), ) + button_description = models.CharField( + _('Login button description'), + max_length=256, + blank=True, + help_text=_( + 'Description will be shown on login page above login button (unless already set by theme).' + ), + ) + button_label = models.CharField(_('Login button label'), max_length=64, default=_('Login')) objects = models.Manager() authenticators = AuthenticatorManager() diff --git a/src/authentic2_auth_fc/forms.py b/src/authentic2_auth_fc/forms.py index bf1e5ca6..b941cab6 100644 --- a/src/authentic2_auth_fc/forms.py +++ b/src/authentic2_auth_fc/forms.py @@ -32,4 +32,4 @@ class FcAuthenticatorForm(AuthenticatorFormMixin, forms.ModelForm): class Meta: model = FcAuthenticator - exclude = ('name', 'slug', 'ou') + exclude = ('name', 'slug', 'ou', 'button_description', 'button_label') diff --git a/tests/test_manager_authenticators.py b/tests/test_manager_authenticators.py index debeeffa..0eac00b6 100644 --- a/tests/test_manager_authenticators.py +++ b/tests/test_manager_authenticators.py @@ -56,6 +56,8 @@ def test_authenticators_password(app, superuser): assert list(resp.form.fields) == [ 'csrfmiddlewaretoken', 'show_condition', + 'button_description', + 'button_label', 'remember_me', 'include_ou_selector', None, -- 2.30.2