
from django.contrib import admin
from django.urls import path, include
from django.conf import settings

from core.views import DashboardView
from core.navigation import Navigation

import importlib

urlpatterns = [
    path('admin/', DashboardView.as_view(), name="backend"),
]

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"))