2018-11-11 12:41:48 +00:00
|
|
|
"""passbook oauth_client config"""
|
2018-11-16 08:10:35 +00:00
|
|
|
from importlib import import_module
|
|
|
|
|
2018-11-11 12:41:48 +00:00
|
|
|
from django.apps import AppConfig
|
2019-10-01 08:24:10 +00:00
|
|
|
from structlog import get_logger
|
2018-11-16 08:10:35 +00:00
|
|
|
|
2018-11-11 12:41:48 +00:00
|
|
|
from passbook.lib.config import CONFIG
|
2018-11-16 08:10:35 +00:00
|
|
|
|
2019-10-01 08:24:10 +00:00
|
|
|
LOGGER = get_logger(__name__)
|
2018-11-11 12:41:48 +00:00
|
|
|
|
|
|
|
class PassbookOAuthClientConfig(AppConfig):
|
|
|
|
"""passbook oauth_client config"""
|
|
|
|
|
|
|
|
name = 'passbook.oauth_client'
|
|
|
|
label = 'passbook_oauth_client'
|
|
|
|
verbose_name = 'passbook OAuth Client'
|
2018-11-22 09:28:13 +00:00
|
|
|
mountpoint = 'source/oauth/'
|
2018-11-11 12:41:48 +00:00
|
|
|
|
|
|
|
def ready(self):
|
|
|
|
"""Load source_types from config file"""
|
2018-11-16 09:08:15 +00:00
|
|
|
source_types_to_load = CONFIG.y('oauth_client.types', [])
|
2018-11-11 12:41:48 +00:00
|
|
|
for source_type in source_types_to_load:
|
|
|
|
try:
|
|
|
|
import_module(source_type)
|
|
|
|
LOGGER.info("Loaded %s", source_type)
|
|
|
|
except ImportError as exc:
|
|
|
|
LOGGER.debug(exc)
|