expephalon-chat/core/modules/urls.py

32 lines
1.5 KiB
Python
Raw Normal View History

import importlib
from django.conf import settings
from django.urls import path
from core.views import DashboardView, LoginView, OTPSelectorView, LogoutView, OTPValidatorView, BackendNotImplementedView
URLPATTERNS = [
path('login/', LoginView.as_view(), name="login"),
path('login/otp/select/', OTPSelectorView.as_view(), name="otpselector"),
path('login/otp/validate/', OTPValidatorView.as_view(), name="otpvalidator"),
path('logout/', LogoutView.as_view(), name="logout"),
path('admin/', DashboardView.as_view(), name="dashboard"),
path('admin/oops/', BackendNotImplementedView.as_view(), name="backendni")
]
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
try:
from core.views import DBSettingsListView, DBSettingsEditView, DBSettingsDeleteView, DBSettingsCreateView
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"))
except:
pass