import importlib

from django.conf import settings
from django.urls import path

URLPATTERNS = []

for module in settings.EXPEPHALON_MODULES:
    try:
        mou = importlib.import_module(f"{module}.urls")
        for url, action, name in mou.ADMIN_URLS:
            URLPATTERNS.append(path(f'admin/modules/{module}/{url}', action, name=f"{module}_{name}"))
    except (AttributeError, ModuleNotFoundError):
        pass

if "dbsettings" in settings.INSTALLED_APPS:
    from core.views import DBSettingsListView
    URLPATTERNS.append(path("admin/dbsettings/", DBSettingsListView.as_view(), name="dbsettings"))