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.python",
"ms-python.vscode-pylance",
"ms-python.black-formatter",
"redhat.vscode-yaml",
"Tobermory.es6-string-html",
"unifiedjs.vscode-mdx",

View file

@ -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",

View file

@ -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:

View file

@ -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,
)

View file

@ -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(

View file

@ -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(