Register applications with Branded name for UI Dropdown

This commit is contained in:
Jens Langhammer 2019-02-23 20:42:14 +01:00
parent 66c0fc9d9a
commit e5a405bf43
6 changed files with 15 additions and 9 deletions

View File

@ -13,7 +13,7 @@ from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect
LOGGER = getLogger(__name__) LOGGER = getLogger(__name__)
@MANAGER.source(kind=RequestKind.redirect, name='discord') @MANAGER.source(kind=RequestKind.redirect, name='Discord')
class DiscordOAuthRedirect(OAuthRedirect): class DiscordOAuthRedirect(OAuthRedirect):
"""Discord OAuth2 Redirect""" """Discord OAuth2 Redirect"""
@ -43,7 +43,7 @@ class DiscordOAuth2Client(OAuth2Client):
return response.json() or response.text return response.json() or response.text
@MANAGER.source(kind=RequestKind.callback, name='discord') @MANAGER.source(kind=RequestKind.callback, name='Discord')
class DiscordOAuth2Callback(OAuthCallback): class DiscordOAuth2Callback(OAuthCallback):
"""Discord OAuth2 Callback""" """Discord OAuth2 Callback"""

View File

@ -7,7 +7,7 @@ from passbook.oauth_client.utils import user_get_or_create
from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect
@MANAGER.source(kind=RequestKind.redirect, name='facebook') @MANAGER.source(kind=RequestKind.redirect, name='Facebook')
class FacebookOAuthRedirect(OAuthRedirect): class FacebookOAuthRedirect(OAuthRedirect):
"""Facebook OAuth2 Redirect""" """Facebook OAuth2 Redirect"""
@ -17,7 +17,7 @@ class FacebookOAuthRedirect(OAuthRedirect):
} }
@MANAGER.source(kind=RequestKind.callback, name='facebook') @MANAGER.source(kind=RequestKind.callback, name='Facebook')
class FacebookOAuth2Callback(OAuthCallback): class FacebookOAuth2Callback(OAuthCallback):
"""Facebook OAuth2 Callback""" """Facebook OAuth2 Callback"""

View File

@ -7,7 +7,7 @@ from passbook.oauth_client.utils import user_get_or_create
from passbook.oauth_client.views.core import OAuthCallback from passbook.oauth_client.views.core import OAuthCallback
@MANAGER.source(kind=RequestKind.callback, name='github') @MANAGER.source(kind=RequestKind.callback, name='GitHub')
class GitHubOAuth2Callback(OAuthCallback): class GitHubOAuth2Callback(OAuthCallback):
"""GitHub OAuth2 Callback""" """GitHub OAuth2 Callback"""

View File

@ -6,7 +6,7 @@ from passbook.oauth_client.utils import user_get_or_create
from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect
@MANAGER.source(kind=RequestKind.redirect, name='google') @MANAGER.source(kind=RequestKind.redirect, name='Google')
class GoogleOAuthRedirect(OAuthRedirect): class GoogleOAuthRedirect(OAuthRedirect):
"""Google OAuth2 Redirect""" """Google OAuth2 Redirect"""
@ -16,7 +16,7 @@ class GoogleOAuthRedirect(OAuthRedirect):
} }
@MANAGER.source(kind=RequestKind.callback, name='google') @MANAGER.source(kind=RequestKind.callback, name='Google')
class GoogleOAuth2Callback(OAuthCallback): class GoogleOAuth2Callback(OAuthCallback):
"""Google OAuth2 Callback""" """Google OAuth2 Callback"""

View File

@ -17,17 +17,23 @@ class SourceTypeManager:
"""Manager to hold all Source types.""" """Manager to hold all Source types."""
__source_types = {} __source_types = {}
__names = []
def source(self, kind, name): def source(self, kind, name):
"""Class decorator to register classes inline.""" """Class decorator to register classes inline."""
def inner_wrapper(cls): def inner_wrapper(cls):
if kind not in self.__source_types: if kind not in self.__source_types:
self.__source_types[kind] = {} self.__source_types[kind] = {}
self.__source_types[kind][name] = cls self.__source_types[kind][name.lower()] = cls
self.__names.append(name)
LOGGER.debug("Registered source '%s' for '%s'", cls.__name__, kind) LOGGER.debug("Registered source '%s' for '%s'", cls.__name__, kind)
return cls return cls
return inner_wrapper return inner_wrapper
def get_name_tuple(self):
"""Get list of tuples of all registered names"""
return [(x.lower(), x) for x in set(self.__names)]
def find(self, source, kind): def find(self, source, kind):
"""Find fitting Source Type""" """Find fitting Source Type"""
if kind in self.__source_types: if kind in self.__source_types:

View File

@ -29,7 +29,7 @@ class TwitterOAuthClient(OAuthClient):
return response.json() or response.text return response.json() or response.text
@MANAGER.source(kind=RequestKind.callback, name='twitter') @MANAGER.source(kind=RequestKind.callback, name='Twitter')
class TwitterOAuthCallback(OAuthCallback): class TwitterOAuthCallback(OAuthCallback):
"""Twitter OAuth2 Callback""" """Twitter OAuth2 Callback"""