stages/*: simplify __str__ of classes

This commit is contained in:
Jens Langhammer 2021-03-01 18:30:47 +01:00
parent 37b59bb5b9
commit 03d38557e5
14 changed files with 3 additions and 39 deletions

View File

@ -72,7 +72,7 @@ class Stage(SerializerModel):
def __str__(self): def __str__(self):
if hasattr(self, "__in_memory_type"): if hasattr(self, "__in_memory_type"):
return f"In-memory Stage {getattr(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: def in_memory_stage(view: Type["StageView"]) -> Stage:

View File

@ -138,7 +138,7 @@ class Policy(SerializerModel, CreatedUpdatedModel):
raise NotImplementedError raise NotImplementedError
def __str__(self): def __str__(self):
return f"{self.__class__.__name__} {self.name}" return self.name
def passes(self, request: PolicyRequest) -> PolicyResult: # pragma: no cover def passes(self, request: PolicyRequest) -> PolicyResult: # pragma: no cover
"""Check if request passes this policy""" """Check if request passes this policy"""

View File

@ -66,9 +66,6 @@ class AuthenticatorValidateStage(Stage):
return AuthenticatorValidateStageForm return AuthenticatorValidateStageForm
def __str__(self) -> str:
return f"Authenticator Validation Stage {self.name}"
class Meta: class Meta:
verbose_name = _("Authenticator Validation Stage") verbose_name = _("Authenticator Validation Stage")

View File

@ -42,9 +42,6 @@ class CaptchaStage(Stage):
return CaptchaStageForm return CaptchaStageForm
def __str__(self):
return f"Captcha Stage {self.name}"
class Meta: class Meta:
verbose_name = _("Captcha Stage") verbose_name = _("Captcha Stage")

View File

@ -56,9 +56,6 @@ class ConsentStage(Stage):
return ConsentStageForm return ConsentStageForm
def __str__(self):
return f"Consent Stage {self.name}"
class Meta: class Meta:
verbose_name = _("Consent Stage") verbose_name = _("Consent Stage")

View File

@ -32,9 +32,6 @@ class DummyStage(Stage):
return DummyStageForm return DummyStageForm
def __str__(self):
return f"Dummy Stage {self.name}"
class Meta: class Meta:
verbose_name = _("Dummy Stage") verbose_name = _("Dummy Stage")

View File

@ -89,9 +89,6 @@ class IdentificationStage(Stage):
return IdentificationStageForm return IdentificationStageForm
def __str__(self):
return f"Identification Stage {self.name}"
class Meta: class Meta:
verbose_name = _("Identification Stage") verbose_name = _("Identification Stage")

View File

@ -45,9 +45,6 @@ class InvitationStage(Stage):
return InvitationStageForm return InvitationStageForm
def __str__(self):
return f"Invitation Stage {self.name}"
class Meta: class Meta:
verbose_name = _("Invitation Stage") verbose_name = _("Invitation Stage")

View File

@ -55,9 +55,6 @@ class PasswordStage(ConfigurableStage, Stage):
"authentik_stages_password:user-settings", kwargs={"stage_uuid": self.pk} "authentik_stages_password:user-settings", kwargs={"stage_uuid": self.pk}
) )
def __str__(self):
return f"Password Stage {self.name}"
class Meta: class Meta:
verbose_name = _("Password Stage") verbose_name = _("Password Stage")

View File

@ -115,7 +115,7 @@ class Prompt(SerializerModel):
return super().save(*args, **kwargs) return super().save(*args, **kwargs)
def __str__(self): def __str__(self):
return f"Prompt '{self.field_key}' type={self.type}" return f"Prompt field '{self.field_key}' type {self.type}"
class Meta: class Meta:
@ -148,9 +148,6 @@ class PromptStage(Stage):
return PromptStageForm return PromptStageForm
def __str__(self):
return f"Prompt Stage {self.name}"
class Meta: class Meta:
verbose_name = _("Prompt Stage") verbose_name = _("Prompt Stage")

View File

@ -31,9 +31,6 @@ class UserDeleteStage(Stage):
return UserDeleteStageForm return UserDeleteStageForm
def __str__(self):
return f"User Delete Stage {self.name}"
class Meta: class Meta:
verbose_name = _("User Delete Stage") verbose_name = _("User Delete Stage")

View File

@ -42,9 +42,6 @@ class UserLoginStage(Stage):
return UserLoginStageForm return UserLoginStageForm
def __str__(self):
return f"User Login Stage {self.name}"
class Meta: class Meta:
verbose_name = _("User Login Stage") verbose_name = _("User Login Stage")

View File

@ -30,9 +30,6 @@ class UserLogoutStage(Stage):
return UserLogoutStageForm return UserLogoutStageForm
def __str__(self):
return f"User Logout Stage {self.name}"
class Meta: class Meta:
verbose_name = _("User Logout Stage") verbose_name = _("User Logout Stage")

View File

@ -31,9 +31,6 @@ class UserWriteStage(Stage):
return UserWriteStageForm return UserWriteStageForm
def __str__(self):
return f"User Write Stage {self.name}"
class Meta: class Meta:
verbose_name = _("User Write Stage") verbose_name = _("User Write Stage")