From 03d38557e50b4631e3ec3ddb2bb9d45223f136a4 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 1 Mar 2021 18:30:47 +0100 Subject: [PATCH] stages/*: simplify __str__ of classes --- authentik/flows/models.py | 2 +- authentik/policies/models.py | 2 +- authentik/stages/authenticator_validate/models.py | 3 --- authentik/stages/captcha/models.py | 3 --- authentik/stages/consent/models.py | 3 --- authentik/stages/dummy/models.py | 3 --- authentik/stages/identification/models.py | 3 --- authentik/stages/invitation/models.py | 3 --- authentik/stages/password/models.py | 3 --- authentik/stages/prompt/models.py | 5 +---- authentik/stages/user_delete/models.py | 3 --- authentik/stages/user_login/models.py | 3 --- authentik/stages/user_logout/models.py | 3 --- authentik/stages/user_write/models.py | 3 --- 14 files changed, 3 insertions(+), 39 deletions(-) diff --git a/authentik/flows/models.py b/authentik/flows/models.py index 45f0f61ba..b7f1cd758 100644 --- a/authentik/flows/models.py +++ b/authentik/flows/models.py @@ -72,7 +72,7 @@ class Stage(SerializerModel): def __str__(self): if hasattr(self, "__in_memory_type"): return f"In-memory Stage {getattr(self, '__in_memory_type')}" - return f"Stage {self.name}" + return self.name def in_memory_stage(view: Type["StageView"]) -> Stage: diff --git a/authentik/policies/models.py b/authentik/policies/models.py index a495cc73d..9ad95422a 100644 --- a/authentik/policies/models.py +++ b/authentik/policies/models.py @@ -138,7 +138,7 @@ class Policy(SerializerModel, CreatedUpdatedModel): raise NotImplementedError def __str__(self): - return f"{self.__class__.__name__} {self.name}" + return self.name def passes(self, request: PolicyRequest) -> PolicyResult: # pragma: no cover """Check if request passes this policy""" diff --git a/authentik/stages/authenticator_validate/models.py b/authentik/stages/authenticator_validate/models.py index 73d060751..4938be2db 100644 --- a/authentik/stages/authenticator_validate/models.py +++ b/authentik/stages/authenticator_validate/models.py @@ -66,9 +66,6 @@ class AuthenticatorValidateStage(Stage): return AuthenticatorValidateStageForm - def __str__(self) -> str: - return f"Authenticator Validation Stage {self.name}" - class Meta: verbose_name = _("Authenticator Validation Stage") diff --git a/authentik/stages/captcha/models.py b/authentik/stages/captcha/models.py index c6eeac1f3..d2a0fe501 100644 --- a/authentik/stages/captcha/models.py +++ b/authentik/stages/captcha/models.py @@ -42,9 +42,6 @@ class CaptchaStage(Stage): return CaptchaStageForm - def __str__(self): - return f"Captcha Stage {self.name}" - class Meta: verbose_name = _("Captcha Stage") diff --git a/authentik/stages/consent/models.py b/authentik/stages/consent/models.py index 5598da54c..4a96944e2 100644 --- a/authentik/stages/consent/models.py +++ b/authentik/stages/consent/models.py @@ -56,9 +56,6 @@ class ConsentStage(Stage): return ConsentStageForm - def __str__(self): - return f"Consent Stage {self.name}" - class Meta: verbose_name = _("Consent Stage") diff --git a/authentik/stages/dummy/models.py b/authentik/stages/dummy/models.py index 3dfb768bd..344868a82 100644 --- a/authentik/stages/dummy/models.py +++ b/authentik/stages/dummy/models.py @@ -32,9 +32,6 @@ class DummyStage(Stage): return DummyStageForm - def __str__(self): - return f"Dummy Stage {self.name}" - class Meta: verbose_name = _("Dummy Stage") diff --git a/authentik/stages/identification/models.py b/authentik/stages/identification/models.py index 88b20a966..a7b2f4218 100644 --- a/authentik/stages/identification/models.py +++ b/authentik/stages/identification/models.py @@ -89,9 +89,6 @@ class IdentificationStage(Stage): return IdentificationStageForm - def __str__(self): - return f"Identification Stage {self.name}" - class Meta: verbose_name = _("Identification Stage") diff --git a/authentik/stages/invitation/models.py b/authentik/stages/invitation/models.py index be3982744..7d97a0ebb 100644 --- a/authentik/stages/invitation/models.py +++ b/authentik/stages/invitation/models.py @@ -45,9 +45,6 @@ class InvitationStage(Stage): return InvitationStageForm - def __str__(self): - return f"Invitation Stage {self.name}" - class Meta: verbose_name = _("Invitation Stage") diff --git a/authentik/stages/password/models.py b/authentik/stages/password/models.py index e599d49cd..7992fd45d 100644 --- a/authentik/stages/password/models.py +++ b/authentik/stages/password/models.py @@ -55,9 +55,6 @@ class PasswordStage(ConfigurableStage, Stage): "authentik_stages_password:user-settings", kwargs={"stage_uuid": self.pk} ) - def __str__(self): - return f"Password Stage {self.name}" - class Meta: verbose_name = _("Password Stage") diff --git a/authentik/stages/prompt/models.py b/authentik/stages/prompt/models.py index 46d55b870..e7450725b 100644 --- a/authentik/stages/prompt/models.py +++ b/authentik/stages/prompt/models.py @@ -115,7 +115,7 @@ class Prompt(SerializerModel): return super().save(*args, **kwargs) def __str__(self): - return f"Prompt '{self.field_key}' type={self.type}" + return f"Prompt field '{self.field_key}' type {self.type}" class Meta: @@ -148,9 +148,6 @@ class PromptStage(Stage): return PromptStageForm - def __str__(self): - return f"Prompt Stage {self.name}" - class Meta: verbose_name = _("Prompt Stage") diff --git a/authentik/stages/user_delete/models.py b/authentik/stages/user_delete/models.py index f9ef53e00..7e791e8c0 100644 --- a/authentik/stages/user_delete/models.py +++ b/authentik/stages/user_delete/models.py @@ -31,9 +31,6 @@ class UserDeleteStage(Stage): return UserDeleteStageForm - def __str__(self): - return f"User Delete Stage {self.name}" - class Meta: verbose_name = _("User Delete Stage") diff --git a/authentik/stages/user_login/models.py b/authentik/stages/user_login/models.py index d25018f79..db885dbd3 100644 --- a/authentik/stages/user_login/models.py +++ b/authentik/stages/user_login/models.py @@ -42,9 +42,6 @@ class UserLoginStage(Stage): return UserLoginStageForm - def __str__(self): - return f"User Login Stage {self.name}" - class Meta: verbose_name = _("User Login Stage") diff --git a/authentik/stages/user_logout/models.py b/authentik/stages/user_logout/models.py index c59ff085c..8f07a5236 100644 --- a/authentik/stages/user_logout/models.py +++ b/authentik/stages/user_logout/models.py @@ -30,9 +30,6 @@ class UserLogoutStage(Stage): return UserLogoutStageForm - def __str__(self): - return f"User Logout Stage {self.name}" - class Meta: verbose_name = _("User Logout Stage") diff --git a/authentik/stages/user_write/models.py b/authentik/stages/user_write/models.py index 820b5bd92..f4d8b63c4 100644 --- a/authentik/stages/user_write/models.py +++ b/authentik/stages/user_write/models.py @@ -31,9 +31,6 @@ class UserWriteStage(Stage): return UserWriteStageForm - def __str__(self): - return f"User Write Stage {self.name}" - class Meta: verbose_name = _("User Write Stage")