*: rename objectType to component to get rid of lookup tables

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-04-03 11:32:17 +02:00
parent aaebd01058
commit 42cb55d78a
26 changed files with 236 additions and 295 deletions

View File

@ -36,11 +36,11 @@ class PropertyMappingTestResultSerializer(PassiveSerializer):
class PropertyMappingSerializer(ManagedSerializer, ModelSerializer, MetaNameSerializer):
"""PropertyMapping Serializer"""
object_type = SerializerMethodField()
component = SerializerMethodField()
def get_object_type(self, obj: PropertyMapping) -> str:
"""Get object type so that we know which API Endpoint to use to get the full object"""
return obj._meta.object_name.lower().replace("propertymapping", "")
def get_component(self, obj: PropertyMapping) -> str:
"""Get object's component so that we know how to edit the object"""
return obj.component
def validate_expression(self, expression: str) -> str:
"""Test Syntax"""
@ -56,7 +56,7 @@ class PropertyMappingSerializer(ManagedSerializer, ModelSerializer, MetaNameSeri
"managed",
"name",
"expression",
"object_type",
"component",
"verbose_name",
"verbose_name_plural",
]

View File

@ -21,11 +21,11 @@ class ProviderSerializer(ModelSerializer, MetaNameSerializer):
assigned_application_slug = ReadOnlyField(source="application.slug")
assigned_application_name = ReadOnlyField(source="application.name")
object_type = SerializerMethodField()
component = SerializerMethodField()
def get_object_type(self, obj): # pragma: no cover
"""Get object type so that we know which API Endpoint to use to get the full object"""
return obj._meta.object_name.lower().replace("provider", "")
def get_component(self, obj: Provider): # pragma: no cover
"""Get object component so that we know how to edit the object"""
return obj.component
class Meta:
@ -35,7 +35,7 @@ class ProviderSerializer(ModelSerializer, MetaNameSerializer):
"name",
"authorization_flow",
"property_mappings",
"object_type",
"component",
"assigned_application_slug",
"assigned_application_name",
"verbose_name",

View File

@ -23,11 +23,11 @@ LOGGER = get_logger()
class SourceSerializer(ModelSerializer, MetaNameSerializer):
"""Source Serializer"""
object_type = SerializerMethodField()
component = SerializerMethodField()
def get_object_type(self, obj):
"""Get object type so that we know which API Endpoint to use to get the full object"""
return obj._meta.object_name.lower().replace("source", "")
def get_component(self, obj: Source):
"""Get object component so that we know how to edit the object"""
return obj.component
class Meta:
@ -39,7 +39,7 @@ class SourceSerializer(ModelSerializer, MetaNameSerializer):
"enabled",
"authentication_flow",
"enrollment_flow",
"object_type",
"component",
"verbose_name",
"verbose_name_plural",
"policy_engine_mode",