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 <jens@goauthentik.io>

* remove deprecated vscode settings

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-11-21 21:38:30 +01:00 committed by GitHub
parent b0c00d0e6c
commit 68d266a480
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 10 deletions

View file

@ -14,6 +14,7 @@
"ms-python.pylint", "ms-python.pylint",
"ms-python.python", "ms-python.python",
"ms-python.vscode-pylance", "ms-python.vscode-pylance",
"ms-python.black-formatter",
"redhat.vscode-yaml", "redhat.vscode-yaml",
"Tobermory.es6-string-html", "Tobermory.es6-string-html",
"unifiedjs.vscode-mdx", "unifiedjs.vscode-mdx",

View file

@ -19,10 +19,8 @@
"slo", "slo",
"scim", "scim",
], ],
"python.linting.pylintEnabled": true,
"todo-tree.tree.showCountsInTree": true, "todo-tree.tree.showCountsInTree": true,
"todo-tree.tree.showBadges": true, "todo-tree.tree.showBadges": true,
"python.formatting.provider": "black",
"yaml.customTags": [ "yaml.customTags": [
"!Find sequence", "!Find sequence",
"!KeyOf scalar", "!KeyOf scalar",

View file

@ -517,7 +517,7 @@ class Source(ManagedModel, SerializerModel, PolicyBindingModel):
objects = InheritanceManager() objects = InheritanceManager()
@property @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 """Get the URL to the Icon. If the name is /static or
starts with http it is returned as-is""" starts with http it is returned as-is"""
if not self.icon: if not self.icon:

View file

@ -74,7 +74,7 @@ class OAuthSource(Source):
def ui_login_button(self, request: HttpRequest) -> UILoginButton: def ui_login_button(self, request: HttpRequest) -> UILoginButton:
provider_type = self.source_type provider_type = self.source_type
provider = provider_type() provider = provider_type()
icon = self.get_icon icon = self.icon_url
if not icon: if not icon:
icon = provider.icon_url() icon = provider.icon_url()
return UILoginButton( return UILoginButton(
@ -85,7 +85,7 @@ class OAuthSource(Source):
def ui_user_settings(self) -> Optional[UserSettingSerializer]: def ui_user_settings(self) -> Optional[UserSettingSerializer]:
provider_type = self.source_type provider_type = self.source_type
icon = self.get_icon icon = self.icon_url
if not icon: if not icon:
icon = provider_type().icon_url() icon = provider_type().icon_url()
return UserSettingSerializer( return UserSettingSerializer(
@ -232,7 +232,7 @@ class UserOAuthSourceConnection(UserSourceConnection):
access_token = models.TextField(blank=True, null=True, default=None) access_token = models.TextField(blank=True, null=True, default=None)
@property @property
def serializer(self) -> Serializer: def serializer(self) -> type[Serializer]:
from authentik.sources.oauth.api.source_connection import ( from authentik.sources.oauth.api.source_connection import (
UserOAuthSourceConnectionSerializer, UserOAuthSourceConnectionSerializer,
) )

View file

@ -62,7 +62,7 @@ class PlexSource(Source):
return PlexSourceSerializer return PlexSourceSerializer
def ui_login_button(self, request: HttpRequest) -> UILoginButton: def ui_login_button(self, request: HttpRequest) -> UILoginButton:
icon = self.get_icon icon = self.icon_url
if not icon: if not icon:
icon = static("authentik/sources/plex.svg") icon = static("authentik/sources/plex.svg")
return UILoginButton( return UILoginButton(
@ -79,7 +79,7 @@ class PlexSource(Source):
) )
def ui_user_settings(self) -> Optional[UserSettingSerializer]: def ui_user_settings(self) -> Optional[UserSettingSerializer]:
icon = self.get_icon icon = self.icon_url
if not icon: if not icon:
icon = static("authentik/sources/plex.svg") icon = static("authentik/sources/plex.svg")
return UserSettingSerializer( return UserSettingSerializer(

View file

@ -200,11 +200,11 @@ class SAMLSource(Source):
} }
), ),
name=self.name, name=self.name,
icon_url=self.get_icon, icon_url=self.icon_url,
) )
def ui_user_settings(self) -> Optional[UserSettingSerializer]: def ui_user_settings(self) -> Optional[UserSettingSerializer]:
icon = self.get_icon icon = self.icon_url
if not icon: if not icon:
icon = static(f"authentik/sources/{self.slug}.svg") icon = static(f"authentik/sources/{self.slug}.svg")
return UserSettingSerializer( return UserSettingSerializer(