Register applications with Branded name for UI Dropdown
This commit is contained in:
parent
66c0fc9d9a
commit
e5a405bf43
|
@ -13,7 +13,7 @@ from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect
|
|||
LOGGER = getLogger(__name__)
|
||||
|
||||
|
||||
@MANAGER.source(kind=RequestKind.redirect, name='discord')
|
||||
@MANAGER.source(kind=RequestKind.redirect, name='Discord')
|
||||
class DiscordOAuthRedirect(OAuthRedirect):
|
||||
"""Discord OAuth2 Redirect"""
|
||||
|
||||
|
@ -43,7 +43,7 @@ class DiscordOAuth2Client(OAuth2Client):
|
|||
return response.json() or response.text
|
||||
|
||||
|
||||
@MANAGER.source(kind=RequestKind.callback, name='discord')
|
||||
@MANAGER.source(kind=RequestKind.callback, name='Discord')
|
||||
class DiscordOAuth2Callback(OAuthCallback):
|
||||
"""Discord OAuth2 Callback"""
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from passbook.oauth_client.utils import user_get_or_create
|
|||
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):
|
||||
"""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):
|
||||
"""Facebook OAuth2 Callback"""
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from passbook.oauth_client.utils import user_get_or_create
|
|||
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):
|
||||
"""GitHub OAuth2 Callback"""
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from passbook.oauth_client.utils import user_get_or_create
|
|||
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):
|
||||
"""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):
|
||||
"""Google OAuth2 Callback"""
|
||||
|
||||
|
|
|
@ -17,17 +17,23 @@ class SourceTypeManager:
|
|||
"""Manager to hold all Source types."""
|
||||
|
||||
__source_types = {}
|
||||
__names = []
|
||||
|
||||
def source(self, kind, name):
|
||||
"""Class decorator to register classes inline."""
|
||||
def inner_wrapper(cls):
|
||||
if kind not in self.__source_types:
|
||||
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)
|
||||
return cls
|
||||
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):
|
||||
"""Find fitting Source Type"""
|
||||
if kind in self.__source_types:
|
||||
|
|
|
@ -29,7 +29,7 @@ class TwitterOAuthClient(OAuthClient):
|
|||
return response.json() or response.text
|
||||
|
||||
|
||||
@MANAGER.source(kind=RequestKind.callback, name='twitter')
|
||||
@MANAGER.source(kind=RequestKind.callback, name='Twitter')
|
||||
class TwitterOAuthCallback(OAuthCallback):
|
||||
"""Twitter OAuth2 Callback"""
|
||||
|
||||
|
|
Reference in a new issue