2019-06-25 16:00:54 +00: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 08:24:10 +00:00
|
|
|
from structlog import get_logger
|
2019-06-25 16:00:54 +00: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 16:00:54 +00:00
|
|
|
|
2019-10-04 08:08:53 +00:00
|
|
|
LOGGER = get_logger()
|
2019-06-25 16:00:54 +00:00
|
|
|
admin.autodiscover()
|
2019-12-31 11:51:16 +00:00
|
|
|
admin.site.login = RedirectView.as_view(pattern_name="passbook_core:auth-login")
|
2019-06-25 16:00:54 +00: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 16:00:54 +00:00
|
|
|
|
|
|
|
for _passbook_app in get_apps():
|
2019-12-31 11:51:16 +00:00
|
|
|
if hasattr(_passbook_app, "mountpoint"):
|
|
|
|
_path = path(
|
|
|
|
_passbook_app.mountpoint,
|
|
|
|
include(
|
|
|
|
(_passbook_app.name + ".urls", _passbook_app.label),
|
|
|
|
namespace=_passbook_app.label,
|
|
|
|
),
|
|
|
|
)
|
2019-06-25 16:00:54 +00:00
|
|
|
urlpatterns.append(_path)
|
2019-10-04 08:21:33 +00:00
|
|
|
LOGGER.debug("Mounted URLs", app_name=_passbook_app.name)
|
2019-06-25 16:00:54 +00:00
|
|
|
|
|
|
|
urlpatterns += [
|
|
|
|
# Administration
|
2019-12-31 11:51:16 +00:00
|
|
|
path("administration/django/", admin.site.urls),
|
|
|
|
path("metrics", MetricsView.as_view(), name="metrics"),
|
2019-06-25 16:00:54 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
if settings.DEBUG:
|
|
|
|
import debug_toolbar
|
2019-12-31 11:51:16 +00:00
|
|
|
|
|
|
|
urlpatterns = [path("__debug__/", include(debug_toolbar.urls)),] + urlpatterns
|