expephalon-demomodule/core/modules/sms.py
Klaus-Uwe Mitterer d74a4c1b8b User profile models
SMS OTP provider
Login template (without css)
2020-04-13 20:03:01 +02:00

37 lines
No EOL
983 B
Python

import importlib
from django.conf import settings
from dbsettings.functions import getValue
providers = []
modules_available = []
for module in settings.EXPEPHALON_MODULES:
try:
mos = importlib.import_module(f"{module}.sms")
for provider in mos.SMSPROVIDERS:
providers.append(provider)
if mos.CREATE:
modules_available.append(mos.CREATE)
except (AttributeError, ModuleNotFoundError):
continue
def get_sms_provider_by_name(name):
for provider in providers:
if provider.name == name:
return provider
def get_default_sms_provider_name():
return getValue("core.sms.default", False)
def get_default_sms_provider():
name = get_default_sms_provider_name()
if name:
for provider in providers:
if provider.name == name and provider.is_active:
return provider
for provider in providers:
if provider.is_active:
return provider