expephalon/core/modules/urls.py
Klaus-Uwe Mitterer 853a49abe8 Implement brands
More administration pages *whoop-whoop*
2020-05-31 14:08:26 +02:00

76 lines
2.9 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,
RateLimitedView,
BackendNotImplementedView,
AdminListView,
AdminDeleteView,
AdminEditView,
AdminCreateView,
DBSettingsListView,
DBSettingsEditView,
DBSettingsDeleteView,
DBSettingsCreateView,
BrandCreateView,
BrandDeleteView,
BrandEditView,
BrandListView,
)
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"))
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/<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"))
# Brand Administration URLs
URLPATTERNS.append(path('admin/brands/', BrandListView.as_view(), name="brands"))
URLPATTERNS.append(path("admin/brands/<pk>/delete/", BrandDeleteView.as_view(), name="brands_delete"))
URLPATTERNS.append(path("admin/brands/<pk>/edit/", BrandEditView.as_view(), name="brands_edit"))
URLPATTERNS.append(path("admin/brands/create/", BrandCreateView.as_view(), name="brands_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