From 2c0d8d894332f59a75e7f14f76245c1a760c2153 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 26 Nov 2021 10:27:08 +0100 Subject: [PATCH] core: add meta_model_name to MetaNameSerializer to easily show relevant events Signed-off-by: Jens Langhammer --- authentik/core/api/utils.py | 5 +++++ schema.yml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/authentik/core/api/utils.py b/authentik/core/api/utils.py index 2703d3c70..6c28debd6 100644 --- a/authentik/core/api/utils.py +++ b/authentik/core/api/utils.py @@ -41,6 +41,7 @@ class MetaNameSerializer(PassiveSerializer): verbose_name = SerializerMethodField() verbose_name_plural = SerializerMethodField() + meta_model_name = SerializerMethodField() def get_verbose_name(self, obj: Model) -> str: """Return object's verbose_name""" @@ -50,6 +51,10 @@ class MetaNameSerializer(PassiveSerializer): """Return object's plural verbose_name""" return obj._meta.verbose_name_plural + def get_meta_model_name(self, obj: Model) -> str: + """Return internal model name""" + return f"{obj._meta.app_label}.{obj._meta.model_name}" + class TypeCreateSerializer(PassiveSerializer): """Types of an object that can be created""" diff --git a/schema.yml b/schema.yml index a4d1439b0..497e4a655 100644 --- a/schema.yml +++ b/schema.yml @@ -20425,6 +20425,9 @@ components: verbose_name_plural: type: string readOnly: true + meta_model_name: + type: string + readOnly: true pk: type: integer name: @@ -20433,6 +20436,7 @@ components: type: string readOnly: true required: + - meta_model_name - name - pk - type