diff --git a/apps/__init__.py b/apps/__init__.py index f62c895b3..c2e888094 100644 --- a/apps/__init__.py +++ b/apps/__init__.py @@ -1,4 +1,3 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -__version__ = "1.4.9" diff --git a/apps/jumpserver/const.py b/apps/jumpserver/const.py new file mode 100644 index 000000000..808e15527 --- /dev/null +++ b/apps/jumpserver/const.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# +VERSION = '1.4.9' diff --git a/apps/jumpserver/context_processor.py b/apps/jumpserver/context_processor.py index f8967adcf..10cf48a56 100644 --- a/apps/jumpserver/context_processor.py +++ b/apps/jumpserver/context_processor.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # from django.contrib.staticfiles.templatetags.staticfiles import static +from django.conf import settings +from django.utils.translation import gettext_lazy as _ def jumpserver_processor(request): @@ -11,7 +13,9 @@ def jumpserver_processor(request): 'LOGO_TEXT_URL': static('img/logo_text.png'), 'LOGIN_IMAGE_URL': static('img/login_image.png'), 'FAVICON_URL': static('img/facio.ico'), - 'JMS_TITLE': 'Jumpserver' + 'JMS_TITLE': 'Jumpserver', + 'VERSION': settings.VERSION, + 'COPYRIGHT': _('Beijing Duizhan Tech, Inc.') + ' © 2014-2019' } return context diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index d516c097c..bd46309d1 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -12,25 +12,24 @@ https://docs.djangoproject.com/en/1.10/ref/settings/ import os import sys -import socket import ldap from django.urls import reverse_lazy +from .const import VERSION from .conf import load_user_config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PROJECT_DIR = os.path.dirname(BASE_DIR) sys.path.append(PROJECT_DIR) -from apps import __version__ -VERSION = __version__ CONFIG = load_user_config() LOG_DIR = os.path.join(PROJECT_DIR, 'logs') JUMPSERVER_LOG_FILE = os.path.join(LOG_DIR, 'jumpserver.log') ANSIBLE_LOG_FILE = os.path.join(LOG_DIR, 'ansible.log') GUNICORN_LOG_FILE = os.path.join(LOG_DIR, 'gunicorn.log') +VERSION = VERSION if not os.path.isdir(LOG_DIR): os.makedirs(LOG_DIR) @@ -163,7 +162,7 @@ MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage' DB_OPTIONS = {} DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.{}'.format(CONFIG.DB_ENGINE), + 'ENGINE': 'django.db.backends.{}'.format(CONFIG.DB_ENGINE.lower()), 'NAME': CONFIG.DB_NAME, 'HOST': CONFIG.DB_HOST, 'PORT': CONFIG.DB_PORT, @@ -174,8 +173,10 @@ DATABASES = { } } DB_CA_PATH = os.path.join(PROJECT_DIR, 'data', 'ca.pem') -if CONFIG.DB_ENGINE == 'mysql' and os.path.isfile(DB_CA_PATH): - DB_OPTIONS['ssl'] = {'ca': DB_CA_PATH} +if CONFIG.DB_ENGINE.lower() == 'mysql': + DB_OPTIONS['init_command'] = "SET sql_mode='STRICT_TRANS_TABLES'" + if os.path.isfile(DB_CA_PATH): + DB_OPTIONS['ssl'] = {'ca': DB_CA_PATH} # Password validation diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index 5bcb3f572..6a7551a66 100644 Binary files a/apps/locale/zh/LC_MESSAGES/django.mo and b/apps/locale/zh/LC_MESSAGES/django.mo differ diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index f0494f3de..dbbd4ebbd 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Jumpserver 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-03-27 12:48+0800\n" +"POT-Creation-Date: 2019-03-27 17:33+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: ibuler \n" "Language-Team: Jumpserver team\n" @@ -2322,6 +2322,10 @@ msgstr "" msgid "Special char not allowed" msgstr "不能包含特殊字符" +#: jumpserver/context_processor.py:18 +msgid "Beijing Duizhan Tech, Inc." +msgstr "北京堆栈科技有限公司" + #: jumpserver/views.py:185 msgid "" "
Luna is a separately deployed program, you need to deploy Luna, coco, " @@ -3347,10 +3351,6 @@ msgstr "创建录像存储" msgid "Create command storage" msgstr "创建命令存储" -#: templates/_copyright.html:2 templates/_footer.html:8 -msgid " Beijing Duizhan Tech, Inc. " -msgstr " 北京堆栈科技有限公司 " - #: templates/_header_bar.html:31 msgid "Help" msgstr "帮助" diff --git a/apps/templates/_copyright.html b/apps/templates/_copyright.html index 327e67bd3..772c24cc5 100644 --- a/apps/templates/_copyright.html +++ b/apps/templates/_copyright.html @@ -1,2 +1,2 @@ {% load i18n %} -Copyright {% trans ' Beijing Duizhan Tech, Inc. ' %} © 2014-2019 \ No newline at end of file +Copyright {{ COPYRIGHT }} \ No newline at end of file diff --git a/apps/templates/_footer.html b/apps/templates/_footer.html index 869ea76a6..21ed61e77 100644 --- a/apps/templates/_footer.html +++ b/apps/templates/_footer.html @@ -1,10 +1,10 @@ {% load i18n %} diff --git a/jms b/jms index bb10b7796..43c345406 100755 --- a/jms +++ b/jms @@ -13,7 +13,8 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, BASE_DIR) try: - from apps import __version__ + from apps.jumpserver import const + __version__ = const.VERSION except ImportError as e: print("Not found __version__: {}".format(e)) print("Sys path: {}".format(sys.path))