import importlib from django.conf import settings from django.urls import path from core.views import ( DashboardView, LoginView, OTPSelectorView, LogoutView, OTPValidatorView, PWResetView, PWRequestView, RateLimitedView, BackendNotImplementedView, AdminListView, AdminDeleteView, AdminEditView, AdminCreateView, DBSettingsListView, DBSettingsEditView, DBSettingsDeleteView, DBSettingsCreateView, ) URLPATTERNS = [] # Auth URLs URLPATTERNS.append(path('login/', LoginView.as_view(), name="login")) URLPATTERNS.append(path('login/otp/select/', OTPSelectorView.as_view(), name="otpselector")) URLPATTERNS.append(path('login/otp/validate/', OTPValidatorView.as_view(), name="otpvalidator")) URLPATTERNS.append(path('logout/', LogoutView.as_view(), name="logout")) URLPATTERNS.append(path('login/reset/', PWRequestView.as_view(), name="pwrequest")) URLPATTERNS.append(path('login/reset//', PWResetView.as_view(), name="pwreset")) URLPATTERNS.append(path('login/ratelimit/', RateLimitedView.as_view(), name="ratelimited")) # Base Backend URLs URLPATTERNS.append(path('admin/', DashboardView.as_view(), name="dashboard")) URLPATTERNS.append(path('admin/oops/', BackendNotImplementedView.as_view(), name="backendni")) # Backend Database Settings URLs URLPATTERNS.append(path("admin/dbsettings/", DBSettingsListView.as_view(), name="dbsettings")) URLPATTERNS.append(path("admin/dbsettings//delete/", DBSettingsDeleteView.as_view(), name="dbsettings_delete")) URLPATTERNS.append(path("admin/dbsettings//edit/", DBSettingsEditView.as_view(), name="dbsettings_edit")) URLPATTERNS.append(path("admin/dbsettings/create/", DBSettingsCreateView.as_view(), name="dbsettings_create")) # Backend User Administration URLs URLPATTERNS.append(path('admin/profiles/', AdminListView.as_view(), name="admins")) URLPATTERNS.append(path("admin/profiles//delete/", AdminDeleteView.as_view(), name="admins_delete")) URLPATTERNS.append(path("admin/profiles//edit/", AdminEditView.as_view(), name="admins_edit")) URLPATTERNS.append(path("admin/profiles/create/", AdminCreateView.as_view(), name="admins_create")) # External Module URLs 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