2018-11-11 12:41:48 +00:00
|
|
|
"""passbook URL Configuration"""
|
2018-11-22 09:28:13 +00:00
|
|
|
from logging import getLogger
|
|
|
|
|
2018-11-11 12:41:48 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.contrib import admin
|
|
|
|
from django.urls import include, path
|
|
|
|
from django.views.generic import RedirectView
|
|
|
|
|
2019-02-16 08:52:37 +00:00
|
|
|
from passbook.core.auth import view
|
2019-03-22 11:16:30 +00:00
|
|
|
from passbook.core.views import authentication, error, overview, user
|
2018-11-22 09:28:13 +00:00
|
|
|
from passbook.lib.utils.reflection import get_apps
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2018-11-22 09:28:13 +00:00
|
|
|
LOGGER = getLogger(__name__)
|
2018-11-11 12:41:48 +00:00
|
|
|
admin.autodiscover()
|
2018-11-16 08:10:35 +00:00
|
|
|
admin.site.login = RedirectView.as_view(pattern_name='passbook_core:auth-login')
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2019-03-22 11:16:30 +00:00
|
|
|
handler400 = error.BadRequestView.as_view()
|
|
|
|
handler403 = error.ForbiddenView.as_view()
|
|
|
|
handler404 = error.NotFoundView.as_view()
|
|
|
|
handler500 = error.BadRequestView.as_view()
|
|
|
|
|
2018-11-16 08:10:35 +00:00
|
|
|
core_urls = [
|
2018-12-10 15:58:35 +00:00
|
|
|
# Authentication views
|
2018-11-11 12:41:48 +00:00
|
|
|
path('auth/login/', authentication.LoginView.as_view(), name='auth-login'),
|
2018-11-23 08:44:30 +00:00
|
|
|
path('auth/logout/', authentication.LogoutView.as_view(), name='auth-logout'),
|
2018-12-10 12:51:16 +00:00
|
|
|
path('auth/sign_up/', authentication.SignUpView.as_view(), name='auth-sign-up'),
|
2019-02-25 20:03:24 +00:00
|
|
|
path('auth/sign_up/<uuid:nonce>/confirm/', authentication.SignUpConfirmView.as_view(),
|
|
|
|
name='auth-sign-up-confirm'),
|
2019-02-25 11:29:40 +00:00
|
|
|
path('auth/process/denied/', view.FactorPermissionDeniedView.as_view(), name='auth-denied'),
|
2019-02-25 19:46:23 +00:00
|
|
|
path('auth/password/reset/<uuid:nonce>/', authentication.PasswordResetView.as_view(),
|
|
|
|
name='auth-password-reset'),
|
2019-02-16 08:52:37 +00:00
|
|
|
path('auth/process/', view.AuthenticationView.as_view(), name='auth-process'),
|
|
|
|
path('auth/process/<slug:factor>/', view.AuthenticationView.as_view(), name='auth-process'),
|
2018-12-10 15:58:35 +00:00
|
|
|
# User views
|
2019-02-26 08:08:49 +00:00
|
|
|
path('_/user/', user.UserSettingsView.as_view(), name='user-settings'),
|
|
|
|
path('_/user/delete/', user.UserDeleteView.as_view(), name='user-delete'),
|
|
|
|
path('_/user/change_password/', user.UserChangePasswordView.as_view(),
|
2019-02-23 19:56:41 +00:00
|
|
|
name='user-change-password'),
|
2018-12-10 15:58:35 +00:00
|
|
|
# Overview
|
2018-11-11 12:41:48 +00:00
|
|
|
path('', overview.OverviewView.as_view(), name='overview'),
|
2018-11-16 08:10:35 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
urlpatterns = [
|
2018-11-22 09:28:13 +00:00
|
|
|
# Core (include our own URLs so namespaces are used everywhere)
|
2018-11-16 08:10:35 +00:00
|
|
|
path('', include((core_urls, 'passbook_core'), namespace='passbook_core')),
|
2018-11-22 09:28:13 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
for _passbook_app in get_apps():
|
|
|
|
if hasattr(_passbook_app, 'mountpoint'):
|
|
|
|
_path = path(_passbook_app.mountpoint, include((_passbook_app.name+'.urls',
|
2018-11-22 12:12:59 +00:00
|
|
|
_passbook_app.label),
|
2018-11-22 09:28:13 +00:00
|
|
|
namespace=_passbook_app.label))
|
|
|
|
urlpatterns.append(_path)
|
|
|
|
LOGGER.debug("Loaded %s's URLs", _passbook_app.name)
|
|
|
|
|
|
|
|
urlpatterns += [
|
2018-11-11 12:41:48 +00:00
|
|
|
# Administration
|
|
|
|
path('administration/django/', admin.site.urls),
|
|
|
|
]
|
|
|
|
|
|
|
|
if settings.DEBUG:
|
|
|
|
import debug_toolbar
|
|
|
|
urlpatterns = [
|
|
|
|
path('__debug__/', include(debug_toolbar.urls)),
|
|
|
|
] + urlpatterns
|