From 67240fb9ad2f1b6c056ef356e2e414076fd9a92b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 17 Apr 2021 19:12:00 +0200 Subject: [PATCH] *: add model_name to TypeCreate API to pass to forms Signed-off-by: Jens Langhammer --- authentik/core/api/propertymappings.py | 1 + authentik/core/api/providers.py | 1 + authentik/core/api/sources.py | 1 + authentik/core/api/utils.py | 1 + authentik/events/api/event.py | 1 + authentik/flows/api/stages.py | 1 + authentik/outposts/api/outpost_service_connections.py | 1 + authentik/policies/api/policies.py | 1 + authentik/stages/email/api.py | 1 + swagger.yaml | 5 +++++ 10 files changed, 14 insertions(+) diff --git a/authentik/core/api/propertymappings.py b/authentik/core/api/propertymappings.py index 05633bf98..88231c76a 100644 --- a/authentik/core/api/propertymappings.py +++ b/authentik/core/api/propertymappings.py @@ -93,6 +93,7 @@ class PropertyMappingViewSet( "description": subclass.__doc__, # pyright: reportGeneralTypeIssues=false "component": subclass().component, + "model_name": subclass._meta.model_name } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/core/api/providers.py b/authentik/core/api/providers.py index 6e549c04c..0bc20c2ff 100644 --- a/authentik/core/api/providers.py +++ b/authentik/core/api/providers.py @@ -78,6 +78,7 @@ class ProviderViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": subclass().component, + "model_name": subclass._meta.model_name } ) data.append( diff --git a/authentik/core/api/sources.py b/authentik/core/api/sources.py index 3cdae4ac1..cef9493e8 100644 --- a/authentik/core/api/sources.py +++ b/authentik/core/api/sources.py @@ -81,6 +81,7 @@ class SourceViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": component, + "model_name": subclass._meta.model_name } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/core/api/utils.py b/authentik/core/api/utils.py index 1a2586399..5005090c3 100644 --- a/authentik/core/api/utils.py +++ b/authentik/core/api/utils.py @@ -48,6 +48,7 @@ class TypeCreateSerializer(PassiveSerializer): name = CharField(required=True) description = CharField(required=True) component = CharField(required=True) + model_name = CharField(required=True) class CacheSerializer(PassiveSerializer): diff --git a/authentik/events/api/event.py b/authentik/events/api/event.py index b13e28c69..135aedb4d 100644 --- a/authentik/events/api/event.py +++ b/authentik/events/api/event.py @@ -157,6 +157,7 @@ class EventViewSet(ReadOnlyModelViewSet): "name": name, "description": "", "component": value, + "model_name": "" } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/flows/api/stages.py b/authentik/flows/api/stages.py index 190903662..1e528c282 100644 --- a/authentik/flows/api/stages.py +++ b/authentik/flows/api/stages.py @@ -80,6 +80,7 @@ class StageViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": subclass().component, + "model_name": subclass._meta.model_name } ) data = sorted(data, key=lambda x: x["name"]) diff --git a/authentik/outposts/api/outpost_service_connections.py b/authentik/outposts/api/outpost_service_connections.py index 4c121f610..2aea17531 100644 --- a/authentik/outposts/api/outpost_service_connections.py +++ b/authentik/outposts/api/outpost_service_connections.py @@ -82,6 +82,7 @@ class ServiceConnectionViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": subclass().component, + "model_name": subclass._meta.model_name } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/policies/api/policies.py b/authentik/policies/api/policies.py index 089790490..d300cf1ad 100644 --- a/authentik/policies/api/policies.py +++ b/authentik/policies/api/policies.py @@ -108,6 +108,7 @@ class PolicyViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": subclass().component, + "model_name": subclass._meta.model_name } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/stages/email/api.py b/authentik/stages/email/api.py index 411aa7c09..27b5d6752 100644 --- a/authentik/stages/email/api.py +++ b/authentik/stages/email/api.py @@ -63,6 +63,7 @@ class EmailStageViewSet(ModelViewSet): "name": value, "description": label, "component": "", + "model_name": "", } ) return Response(TypeCreateSerializer(choices, many=True).data) diff --git a/swagger.yaml b/swagger.yaml index ab213512a..6c5ccd504 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -14771,6 +14771,7 @@ definitions: - name - description - component + - model_name type: object properties: name: @@ -14785,6 +14786,10 @@ definitions: title: Component type: string minLength: 1 + model_name: + title: Model name + type: string + minLength: 1 EventTopPerUser: required: - application