From 28d029a5535790c7a9b21ae0b4c04f5ca86a1019 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 19 Feb 2019 12:18:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jumpserver/settings.py | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index e5f555e65..227fa0f24 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -15,7 +15,6 @@ import sys import socket import ldap -# from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion from django.urls import reverse_lazy from .conf import load_user_config @@ -81,8 +80,14 @@ INSTALLED_APPS = [ XPACK_DIR = os.path.join(BASE_DIR, 'xpack') XPACK_ENABLED = os.path.isdir(XPACK_DIR) +XPACK_TEMPLATES_DIR = [] +XPACK_CONTEXT_PROCESSOR = [] + if XPACK_ENABLED: + from xpack.utils import get_xpack_templates_dir, get_xpack_context_processor INSTALLED_APPS.append('xpack.apps.XpackConfig') + XPACK_TEMPLATES_DIR = get_xpack_templates_dir(BASE_DIR) + XPACK_CONTEXT_PROCESSOR = get_xpack_context_processor() MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', @@ -103,29 +108,10 @@ MIDDLEWARE = [ 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 = [ { '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, 'OPTIONS': { 'context_processors': [ @@ -139,7 +125,7 @@ TEMPLATES = [ 'django.template.context_processors.media', 'jumpserver.context_processor.jumpserver_processor', 'orgs.context_processor.org_processor', - *get_xpack_context_processor(), + *XPACK_CONTEXT_PROCESSOR, ], }, }, From 666ef366e7cc35992089bf7f243d5b74890485e2 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 19 Feb 2019 12:50:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8Dsession?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=9C=A8=E7=BA=BF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/terminal/tasks.py b/apps/terminal/tasks.py index 4603a5240..ffe3347c2 100644 --- a/apps/terminal/tasks.py +++ b/apps/terminal/tasks.py @@ -37,7 +37,7 @@ def delete_terminal_status_period(): def clean_orphan_session(): active_sessions = Session.objects.filter(is_finished=False) for session in active_sessions: - if not session.is_active(): + if session.is_active(): continue session.is_finished = True session.date_end = timezone.now()