From 057fd7512c4ff0f341800bed631ee3d5b3fbbd3d Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 20 Jul 2022 15:48:22 +0200 Subject: [PATCH] auth_fc: set authenticator to be first by default on creation (#66266) --- src/authentic2_auth_fc/models.py | 5 +++++ tests/test_manager_authenticators.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/authentic2_auth_fc/models.py b/src/authentic2_auth_fc/models.py index f804fb24..304cc0bf 100644 --- a/src/authentic2_auth_fc/models.py +++ b/src/authentic2_auth_fc/models.py @@ -83,6 +83,11 @@ class FcAuthenticator(BaseAuthenticator): return FcAuthenticatorForm + def save(self, *args, **kwargs): + if not self.pk: + self.order = -1 + return super().save(*args, **kwargs) + def get_scopes_display(self): scope_dict = {k: v for k, v in SCOPE_CHOICES} return ', '.join(str(scope_dict[scope]) for scope in self.scopes) diff --git a/tests/test_manager_authenticators.py b/tests/test_manager_authenticators.py index 5edb7c88..debeeffa 100644 --- a/tests/test_manager_authenticators.py +++ b/tests/test_manager_authenticators.py @@ -198,6 +198,8 @@ def test_authenticators_fc(app, superuser): assert '/edit/' in resp.location provider = FcAuthenticator.objects.get() + assert provider.order == -1 + resp = app.get(provider.get_absolute_url()) assert 'extra-actions-menu-opener' in resp.text assert 'Platform: Integration' in resp.text -- 2.30.2