flows: set stage name and verbose_name for in_memory stages

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-12-12 16:22:48 +00:00
parent 45eb8baee8
commit 01a897dbc2
1 changed files with 3 additions and 0 deletions

View File

@ -14,6 +14,7 @@ from authentik.core.models import Token
from authentik.core.types import UserSettingSerializer
from authentik.flows.challenge import FlowLayout
from authentik.lib.models import InheritanceForeignKey, SerializerModel
from authentik.lib.utils.reflection import class_to_path
from authentik.policies.models import PolicyBindingModel
if TYPE_CHECKING:
@ -110,6 +111,8 @@ def in_memory_stage(view: type["StageView"], **kwargs) -> Stage:
# we set the view as a separate property and reference a generic function
# that returns that member
setattr(stage, "__in_memory_type", view)
setattr(stage, "name", _("Dynamic In-memory stage: %(doc)s" % {"doc": view.__doc__}))
setattr(stage._meta, "verbose_name", class_to_path(view))
for key, value in kwargs.items():
setattr(stage, key, value)
return stage