2019-06-25 17:00:54 +01:00
|
|
|
"""passbook URL Configuration"""
|
|
|
|
from django.conf import settings
|
|
|
|
from django.contrib import admin
|
|
|
|
from django.urls import include, path
|
|
|
|
from django.views.generic import RedirectView
|
2019-10-01 09:24:10 +01:00
|
|
|
from structlog import get_logger
|
2019-06-25 17:00:54 +01:00
|
|
|
|
|
|
|
from passbook.core.views import error
|
|
|
|
from passbook.lib.utils.reflection import get_apps
|
2019-11-08 11:24:02 +00:00
|
|
|
from passbook.root.monitoring import MetricsView
|
2019-06-25 17:00:54 +01:00
|
|
|
|
2019-10-04 09:08:53 +01:00
|
|
|
LOGGER = get_logger()
|
2019-06-25 17:00:54 +01:00
|
|
|
admin.autodiscover()
|
2020-05-12 14:21:53 +01:00
|
|
|
admin.site.login = RedirectView.as_view(
|
|
|
|
pattern_name="passbook_flows:default-authentication"
|
|
|
|
)
|
2020-05-11 00:12:57 +01:00
|
|
|
admin.site.logout = RedirectView.as_view(
|
2020-09-11 22:21:11 +01:00
|
|
|
pattern_name="passbook_flows:default-invalidation"
|
2020-05-11 00:12:57 +01:00
|
|
|
)
|
2019-06-25 17:00:54 +01:00
|
|
|
|
|
|
|
handler400 = error.BadRequestView.as_view()
|
|
|
|
handler403 = error.ForbiddenView.as_view()
|
|
|
|
handler404 = error.NotFoundView.as_view()
|
|
|
|
handler500 = error.ServerErrorView.as_view()
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
urlpatterns = []
|
2019-06-25 17:00:54 +01:00
|
|
|
|
|
|
|
for _passbook_app in get_apps():
|
2020-08-19 09:32:44 +01:00
|
|
|
mountpoints = None
|
|
|
|
base_url_module = _passbook_app.name + ".urls"
|
2019-12-31 11:51:16 +00:00
|
|
|
if hasattr(_passbook_app, "mountpoint"):
|
2020-08-19 09:32:44 +01:00
|
|
|
mountpoint = getattr(_passbook_app, "mountpoint")
|
|
|
|
mountpoints = {base_url_module: mountpoint}
|
|
|
|
if hasattr(_passbook_app, "mountpoints"):
|
|
|
|
mountpoints = getattr(_passbook_app, "mountpoints")
|
|
|
|
if not mountpoints:
|
|
|
|
continue
|
|
|
|
for module, mountpoint in mountpoints.items():
|
|
|
|
namespace = _passbook_app.label + module.replace(base_url_module, "")
|
2019-12-31 11:51:16 +00:00
|
|
|
_path = path(
|
2020-08-19 09:32:44 +01:00
|
|
|
mountpoint, include((module, _passbook_app.label), namespace=namespace,),
|
2019-12-31 11:51:16 +00:00
|
|
|
)
|
2019-06-25 17:00:54 +01:00
|
|
|
urlpatterns.append(_path)
|
2020-05-07 19:51:06 +01:00
|
|
|
LOGGER.debug(
|
|
|
|
"Mounted URLs",
|
|
|
|
app_name=_passbook_app.name,
|
2020-08-19 09:32:44 +01:00
|
|
|
mountpoint=mountpoint,
|
|
|
|
namespace=namespace,
|
2020-05-07 19:51:06 +01:00
|
|
|
)
|
2019-06-25 17:00:54 +01:00
|
|
|
|
|
|
|
urlpatterns += [
|
2019-12-31 11:51:16 +00:00
|
|
|
path("administration/django/", admin.site.urls),
|
2020-01-17 09:55:11 +00:00
|
|
|
path("metrics/", MetricsView.as_view(), name="metrics"),
|
2019-06-25 17:00:54 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
if settings.DEBUG:
|
|
|
|
import debug_toolbar
|
2019-12-31 11:51:16 +00:00
|
|
|
|
2020-05-27 10:26:48 +01:00
|
|
|
urlpatterns = [path("-/debug/", include(debug_toolbar.urls))] + urlpatterns
|