2016-11-24 10:22:36 +00:00
|
|
|
# ~*~ coding: utf-8 ~*~
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2018-07-27 10:56:40 +00:00
|
|
|
from django.urls import path, include, re_path
|
2016-08-17 14:17:16 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.conf.urls.static import static
|
2018-09-03 03:24:25 +00:00
|
|
|
from django.conf.urls.i18n import i18n_patterns
|
|
|
|
from django.views.i18n import JavaScriptCatalog
|
2016-08-23 15:29:33 +00:00
|
|
|
|
2018-09-03 03:24:25 +00:00
|
|
|
from .views import IndexView, LunaView, I18NView
|
2018-11-23 02:25:35 +00:00
|
|
|
from .swagger import get_swagger_view
|
|
|
|
|
|
|
|
|
|
|
|
api_v1_patterns = [
|
|
|
|
path('api/', include([
|
|
|
|
path('users/v1/', include('users.urls.api_urls', namespace='api-users')),
|
|
|
|
path('assets/v1/', include('assets.urls.api_urls', namespace='api-assets')),
|
|
|
|
path('perms/v1/', include('perms.urls.api_urls', namespace='api-perms')),
|
|
|
|
path('terminal/v1/', include('terminal.urls.api_urls', namespace='api-terminal')),
|
|
|
|
path('ops/v1/', include('ops.urls.api_urls', namespace='api-ops')),
|
|
|
|
path('audits/v1/', include('audits.urls.api_urls', namespace='api-audits')),
|
|
|
|
path('orgs/v1/', include('orgs.urls.api_urls', namespace='api-orgs')),
|
2019-02-26 04:38:20 +00:00
|
|
|
path('settings/v1/', include('settings.urls.api_urls', namespace='api-settings')),
|
2019-03-05 11:47:14 +00:00
|
|
|
path('authentication/v1/', include('authentication.urls.api_urls', namespace='api-auth')),
|
2018-11-23 02:25:35 +00:00
|
|
|
]))
|
|
|
|
]
|
2016-08-23 15:29:33 +00:00
|
|
|
|
2018-11-23 02:25:35 +00:00
|
|
|
api_v2_patterns = [
|
|
|
|
path('api/', include([
|
|
|
|
path('terminal/v2/', include('terminal.urls.api_urls_v2', namespace='api-terminal-v2')),
|
|
|
|
path('users/v2/', include('users.urls.api_urls_v2', namespace='api-users-v2')),
|
|
|
|
]))
|
2018-07-12 16:31:50 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
app_view_patterns = [
|
2018-07-27 10:56:40 +00:00
|
|
|
path('users/', include('users.urls.views_urls', namespace='users')),
|
|
|
|
path('assets/', include('assets.urls.views_urls', namespace='assets')),
|
|
|
|
path('perms/', include('perms.urls.views_urls', namespace='perms')),
|
|
|
|
path('terminal/', include('terminal.urls.views_urls', namespace='terminal')),
|
|
|
|
path('ops/', include('ops.urls.view_urls', namespace='ops')),
|
|
|
|
path('audits/', include('audits.urls.view_urls', namespace='audits')),
|
|
|
|
path('orgs/', include('orgs.urls.views_urls', namespace='orgs')),
|
2018-11-09 06:54:38 +00:00
|
|
|
path('auth/', include('authentication.urls.view_urls'), name='auth'),
|
2018-07-12 16:31:50 +00:00
|
|
|
]
|
|
|
|
|
2018-11-23 02:25:35 +00:00
|
|
|
|
2018-08-03 02:25:41 +00:00
|
|
|
if settings.XPACK_ENABLED:
|
2018-08-06 02:39:22 +00:00
|
|
|
app_view_patterns.append(path('xpack/', include('xpack.urls', namespace='xpack')))
|
2018-08-02 04:36:31 +00:00
|
|
|
|
2018-09-03 03:24:25 +00:00
|
|
|
js_i18n_patterns = i18n_patterns(
|
|
|
|
path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
|
|
|
|
)
|
2018-07-12 16:31:50 +00:00
|
|
|
|
|
|
|
urlpatterns = [
|
2018-07-27 10:56:40 +00:00
|
|
|
path('', IndexView.as_view(), name='index'),
|
2018-11-23 02:25:35 +00:00
|
|
|
path('', include(api_v2_patterns)),
|
|
|
|
path('', include(api_v1_patterns)),
|
2018-07-27 10:56:40 +00:00
|
|
|
path('luna/', LunaView.as_view(), name='luna-error'),
|
2018-09-03 03:24:25 +00:00
|
|
|
path('i18n/<str:lang>/', I18NView.as_view(), name='i18n-switch'),
|
2019-02-26 04:38:20 +00:00
|
|
|
path('settings/', include('settings.urls.view_urls', namespace='settings')),
|
2018-11-23 02:25:35 +00:00
|
|
|
# path('api/v2/', include(api_v2_patterns)),
|
2016-12-05 14:54:38 +00:00
|
|
|
|
2017-12-18 10:38:30 +00:00
|
|
|
# External apps url
|
2018-07-27 10:56:40 +00:00
|
|
|
path('captcha/', include('captcha.urls')),
|
2016-08-08 16:43:11 +00:00
|
|
|
]
|
2018-07-12 16:31:50 +00:00
|
|
|
urlpatterns += app_view_patterns
|
2018-04-14 04:18:15 +00:00
|
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
|
|
|
|
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
2018-09-03 03:24:25 +00:00
|
|
|
urlpatterns += js_i18n_patterns
|
2018-04-12 09:31:37 +00:00
|
|
|
|
2019-03-05 11:47:14 +00:00
|
|
|
handler404 = 'jumpserver.error_views.handler404'
|
|
|
|
handler500 = 'jumpserver.error_views.handler500'
|
|
|
|
|
2016-08-17 14:17:16 +00:00
|
|
|
if settings.DEBUG:
|
2017-07-10 02:26:17 +00:00
|
|
|
urlpatterns += [
|
2018-11-23 02:25:35 +00:00
|
|
|
re_path('^swagger(?P<format>\.json|\.yaml)$',
|
|
|
|
get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
|
|
|
path('docs/', get_swagger_view().with_ui('swagger', cache_timeout=1), name="docs"),
|
|
|
|
path('redoc/', get_swagger_view().with_ui('redoc', cache_timeout=1), name='redoc'),
|
|
|
|
|
|
|
|
re_path('^v2/swagger(?P<format>\.json|\.yaml)$',
|
|
|
|
get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
|
|
|
path('docs/v2/', get_swagger_view("v2").with_ui('swagger', cache_timeout=1), name="docs"),
|
|
|
|
path('redoc/v2/', get_swagger_view("v2").with_ui('redoc', cache_timeout=1), name='redoc'),
|
2018-04-12 09:31:37 +00:00
|
|
|
]
|