Commit 28d029a5 authored by ibuler's avatar ibuler

[Update] 修改settings

parent f9a7cca4
...@@ -15,7 +15,6 @@ import sys ...@@ -15,7 +15,6 @@ import sys
import socket import socket
import ldap import ldap
# from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion
from django.urls import reverse_lazy from django.urls import reverse_lazy
from .conf import load_user_config from .conf import load_user_config
...@@ -81,8 +80,14 @@ INSTALLED_APPS = [ ...@@ -81,8 +80,14 @@ INSTALLED_APPS = [
XPACK_DIR = os.path.join(BASE_DIR, 'xpack') XPACK_DIR = os.path.join(BASE_DIR, 'xpack')
XPACK_ENABLED = os.path.isdir(XPACK_DIR) XPACK_ENABLED = os.path.isdir(XPACK_DIR)
XPACK_TEMPLATES_DIR = []
XPACK_CONTEXT_PROCESSOR = []
if XPACK_ENABLED: if XPACK_ENABLED:
from xpack.utils import get_xpack_templates_dir, get_xpack_context_processor
INSTALLED_APPS.append('xpack.apps.XpackConfig') INSTALLED_APPS.append('xpack.apps.XpackConfig')
XPACK_TEMPLATES_DIR = get_xpack_templates_dir(BASE_DIR)
XPACK_CONTEXT_PROCESSOR = get_xpack_context_processor()
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
...@@ -103,29 +108,10 @@ MIDDLEWARE = [ ...@@ -103,29 +108,10 @@ MIDDLEWARE = [
ROOT_URLCONF = 'jumpserver.urls' ROOT_URLCONF = 'jumpserver.urls'
def get_xpack_context_processor():
if XPACK_ENABLED:
return ['xpack.context_processor.xpack_processor']
return []
def get_xpack_templates_dir():
if XPACK_ENABLED:
dirs = []
from xpack.utils import find_enabled_plugins
for i in find_enabled_plugins():
template_dir = os.path.join(BASE_DIR, 'xpack', 'plugins', i, 'templates')
if os.path.isdir(template_dir):
dirs.append(template_dir)
return dirs
else:
return []
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates'), *get_xpack_templates_dir()], 'DIRS': [os.path.join(BASE_DIR, 'templates'), *XPACK_TEMPLATES_DIR],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
...@@ -139,7 +125,7 @@ TEMPLATES = [ ...@@ -139,7 +125,7 @@ TEMPLATES = [
'django.template.context_processors.media', 'django.template.context_processors.media',
'jumpserver.context_processor.jumpserver_processor', 'jumpserver.context_processor.jumpserver_processor',
'orgs.context_processor.org_processor', 'orgs.context_processor.org_processor',
*get_xpack_context_processor(), *XPACK_CONTEXT_PROCESSOR,
], ],
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment