[Update] 禁用view

This commit is contained in:
ibuler 2020-06-03 10:38:44 +08:00
parent 1a84661ca9
commit b1f5cc7728
2 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,6 @@
# ~*~ coding: utf-8 ~*~ # ~*~ coding: utf-8 ~*~
from __future__ import unicode_literals from __future__ import unicode_literals
import os
from django.urls import path, include, re_path from django.urls import path, include, re_path
from django.conf import settings from django.conf import settings
@ -30,8 +31,7 @@ api_v2 = [
path('users/', include('users.urls.api_urls_v2', namespace='api-users-v2')), path('users/', include('users.urls.api_urls_v2', namespace='api-users-v2')),
] ]
disabled_view_pattern = [
app_view_patterns = [
path('users/', include('users.urls.views_urls', namespace='users')), path('users/', include('users.urls.views_urls', namespace='users')),
path('assets/', include('assets.urls.views_urls', namespace='assets')), path('assets/', include('assets.urls.views_urls', namespace='assets')),
path('perms/', include('perms.urls.views_urls', namespace='perms')), path('perms/', include('perms.urls.views_urls', namespace='perms')),
@ -39,7 +39,6 @@ app_view_patterns = [
path('ops/', include('ops.urls.view_urls', namespace='ops')), path('ops/', include('ops.urls.view_urls', namespace='ops')),
path('audits/', include('audits.urls.view_urls', namespace='audits')), path('audits/', include('audits.urls.view_urls', namespace='audits')),
path('orgs/', include('orgs.urls.views_urls', namespace='orgs')), path('orgs/', include('orgs.urls.views_urls', namespace='orgs')),
path('auth/', include('authentication.urls.view_urls'), name='auth'),
path('applications/', include('applications.urls.views_urls', namespace='applications')), path('applications/', include('applications.urls.views_urls', namespace='applications')),
path('tickets/', include('tickets.urls.views_urls', namespace='tickets')), path('tickets/', include('tickets.urls.views_urls', namespace='tickets')),
re_path(r'flower/(?P<path>.*)', views.celery_flower_view, name='flower-view'), re_path(r'flower/(?P<path>.*)', views.celery_flower_view, name='flower-view'),
@ -51,6 +50,14 @@ app_view_patterns = [
] ]
app_view_patterns = [
path('auth/', include('authentication.urls.view_urls'), name='auth'),
]
if os.environ.get('ENABLE_OLD_VIEW'):
app_view_patterns += disabled_view_pattern
if settings.XPACK_ENABLED: if settings.XPACK_ENABLED:
app_view_patterns.append( app_view_patterns.append(
path('xpack/', include('xpack.urls.view_urls', namespace='xpack')) path('xpack/', include('xpack.urls.view_urls', namespace='xpack'))
@ -68,7 +75,6 @@ apps = [
'users', 'assets', 'perms', 'terminal', 'ops', 'audits', 'orgs', 'auth', 'users', 'assets', 'perms', 'terminal', 'ops', 'audits', 'orgs', 'auth',
'applications', 'tickets', 'settings', 'xpack' 'applications', 'tickets', 'settings', 'xpack'
'flower', 'luna', 'koko', 'ws', 'i18n', 'jsi18n', 'docs', 'redocs', 'flower', 'luna', 'koko', 'ws', 'i18n', 'jsi18n', 'docs', 'redocs',
'zh-hans'
] ]

View File

@ -10,6 +10,9 @@ class IndexView(PermissionsMixin, TemplateView):
template_name = 'index.html' template_name = 'index.html'
permission_classes = [IsValidUser] permission_classes = [IsValidUser]
def get(self, request, *args, **kwargs):
return redirect('/ui/')
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
if not request.user.is_authenticated: if not request.user.is_authenticated:
return self.handle_no_permission() return self.handle_no_permission()