core: add meta_model_name to MetaNameSerializer to easily show relevant events
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
059ccdd592
commit
2c0d8d8943
|
@ -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"""
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in New Issue