expephalon-kumisms/core/modules/urls.py

63 lines
2.4 KiB
Python

import importlib
from django.conf import settings
from django.urls import path
from core.views import (
DashboardView,
LoginView,
OTPSelectorView,
LogoutView,
OTPValidatorView,
PWResetView,
PWRequestView,
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/<pk>/', PWResetView.as_view(), name="pwreset"))
# 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/<pk>/delete/", DBSettingsDeleteView.as_view(), name="dbsettings_delete"))
URLPATTERNS.append(path("admin/dbsettings/<pk>/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/<pk>/delete/", AdminDeleteView.as_view(), name="admins_delete"))
URLPATTERNS.append(path("admin/profiles/<pk>/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