From 68d266a480bdf615e88c9e86cdec057c6086c741 Mon Sep 17 00:00:00 2001 From: Jens L Date: Tue, 21 Nov 2023 21:38:30 +0100 Subject: [PATCH] core: fix sources get icon naming (#7674) * core: rename source's get_icon to clearer signify it being a property Signed-off-by: Jens Langhammer * remove deprecated vscode settings Signed-off-by: Jens Langhammer --------- Signed-off-by: Jens Langhammer --- .vscode/extensions.json | 1 + .vscode/settings.json | 2 -- authentik/core/models.py | 2 +- authentik/sources/oauth/models.py | 6 +++--- authentik/sources/plex/models.py | 4 ++-- authentik/sources/saml/models.py | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 625e45489..dd280d682 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -14,6 +14,7 @@ "ms-python.pylint", "ms-python.python", "ms-python.vscode-pylance", + "ms-python.black-formatter", "redhat.vscode-yaml", "Tobermory.es6-string-html", "unifiedjs.vscode-mdx", diff --git a/.vscode/settings.json b/.vscode/settings.json index e674c02b5..218800d1e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,10 +19,8 @@ "slo", "scim", ], - "python.linting.pylintEnabled": true, "todo-tree.tree.showCountsInTree": true, "todo-tree.tree.showBadges": true, - "python.formatting.provider": "black", "yaml.customTags": [ "!Find sequence", "!KeyOf scalar", diff --git a/authentik/core/models.py b/authentik/core/models.py index 5365ef693..7d11af3d6 100644 --- a/authentik/core/models.py +++ b/authentik/core/models.py @@ -517,7 +517,7 @@ class Source(ManagedModel, SerializerModel, PolicyBindingModel): objects = InheritanceManager() @property - def get_icon(self) -> Optional[str]: + def icon_url(self) -> Optional[str]: """Get the URL to the Icon. If the name is /static or starts with http it is returned as-is""" if not self.icon: diff --git a/authentik/sources/oauth/models.py b/authentik/sources/oauth/models.py index 6b871fe55..7acbb9223 100644 --- a/authentik/sources/oauth/models.py +++ b/authentik/sources/oauth/models.py @@ -74,7 +74,7 @@ class OAuthSource(Source): def ui_login_button(self, request: HttpRequest) -> UILoginButton: provider_type = self.source_type provider = provider_type() - icon = self.get_icon + icon = self.icon_url if not icon: icon = provider.icon_url() return UILoginButton( @@ -85,7 +85,7 @@ class OAuthSource(Source): def ui_user_settings(self) -> Optional[UserSettingSerializer]: provider_type = self.source_type - icon = self.get_icon + icon = self.icon_url if not icon: icon = provider_type().icon_url() return UserSettingSerializer( @@ -232,7 +232,7 @@ class UserOAuthSourceConnection(UserSourceConnection): access_token = models.TextField(blank=True, null=True, default=None) @property - def serializer(self) -> Serializer: + def serializer(self) -> type[Serializer]: from authentik.sources.oauth.api.source_connection import ( UserOAuthSourceConnectionSerializer, ) diff --git a/authentik/sources/plex/models.py b/authentik/sources/plex/models.py index 06d46dc67..e20c809a3 100644 --- a/authentik/sources/plex/models.py +++ b/authentik/sources/plex/models.py @@ -62,7 +62,7 @@ class PlexSource(Source): return PlexSourceSerializer def ui_login_button(self, request: HttpRequest) -> UILoginButton: - icon = self.get_icon + icon = self.icon_url if not icon: icon = static("authentik/sources/plex.svg") return UILoginButton( @@ -79,7 +79,7 @@ class PlexSource(Source): ) def ui_user_settings(self) -> Optional[UserSettingSerializer]: - icon = self.get_icon + icon = self.icon_url if not icon: icon = static("authentik/sources/plex.svg") return UserSettingSerializer( diff --git a/authentik/sources/saml/models.py b/authentik/sources/saml/models.py index 5f01b034e..6c24abf8d 100644 --- a/authentik/sources/saml/models.py +++ b/authentik/sources/saml/models.py @@ -200,11 +200,11 @@ class SAMLSource(Source): } ), name=self.name, - icon_url=self.get_icon, + icon_url=self.icon_url, ) def ui_user_settings(self) -> Optional[UserSettingSerializer]: - icon = self.get_icon + icon = self.icon_url if not icon: icon = static(f"authentik/sources/{self.slug}.svg") return UserSettingSerializer(