Commit 17181db8 authored by ibuler's avatar ibuler

[Feature] 支持es存储

parents 41f1c3f7 67001dd9
...@@ -78,9 +78,6 @@ class BasicSettingForm(BaseForm): ...@@ -78,9 +78,6 @@ class BasicSettingForm(BaseForm):
max_length=1024, label=_("Email Subject Prefix"), max_length=1024, label=_("Email Subject Prefix"),
initial="[Jumpserver] " initial="[Jumpserver] "
) )
AUTH_LDAP = forms.BooleanField(
label=_("Enable LDAP Auth"), initial=False, required=False
)
class EmailSettingForm(BaseForm): class EmailSettingForm(BaseForm):
......
...@@ -28,8 +28,6 @@ class BasicSettingView(AdminUserRequiredMixin, TemplateView): ...@@ -28,8 +28,6 @@ class BasicSettingView(AdminUserRequiredMixin, TemplateView):
form = self.form_class(request.POST) form = self.form_class(request.POST)
if form.is_valid(): if form.is_valid():
form.save() form.save()
if "AUTH_LDAP" in form.cleaned_data:
ldap_auth_enable.send(form.cleaned_data["AUTH_LDAP"])
msg = _("Update setting successfully, please restart program") msg = _("Update setting successfully, please restart program")
messages.success(request, msg) messages.success(request, msg)
return redirect('settings:basic-setting') return redirect('settings:basic-setting')
...@@ -82,6 +80,8 @@ class LDAPSettingView(AdminUserRequiredMixin, TemplateView): ...@@ -82,6 +80,8 @@ class LDAPSettingView(AdminUserRequiredMixin, TemplateView):
form = self.form_class(request.POST) form = self.form_class(request.POST)
if form.is_valid(): if form.is_valid():
form.save() form.save()
if "AUTH_LDAP" in form.cleaned_data:
ldap_auth_enable.send(form.cleaned_data["AUTH_LDAP"])
msg = _("Update setting successfully, please restart program") msg = _("Update setting successfully, please restart program")
messages.success(request, msg) messages.success(request, msg)
return redirect('settings:ldap-setting') return redirect('settings:ldap-setting')
......
...@@ -391,6 +391,7 @@ TERMINAL_COMMAND_STORAGE = { ...@@ -391,6 +391,7 @@ TERMINAL_COMMAND_STORAGE = {
# } # }
} }
# Django bootstrap3 setting, more see http://django-bootstrap3.readthedocs.io/en/latest/settings.html # Django bootstrap3 setting, more see http://django-bootstrap3.readthedocs.io/en/latest/settings.html
BOOTSTRAP3 = { BOOTSTRAP3 = {
'horizontal_label_class': 'col-md-2', 'horizontal_label_class': 'col-md-2',
......
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n" "Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-12 18:51+0800\n" "POT-Creation-Date: 2018-01-17 17:26+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n" "Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n" "Language-Team: Jumpserver team<ibuler@qq.com>\n"
...@@ -129,7 +129,7 @@ msgid "Password or private key password" ...@@ -129,7 +129,7 @@ msgid "Password or private key password"
msgstr "密码或秘钥不合法" msgstr "密码或秘钥不合法"
#: assets/forms.py:201 assets/forms.py:262 assets/models/user.py:30 #: assets/forms.py:201 assets/forms.py:262 assets/models/user.py:30
#: common/forms.py:110 users/forms.py:16 users/forms.py:24 #: common/forms.py:107 users/forms.py:16 users/forms.py:24
#: users/templates/users/login.html:56 #: users/templates/users/login.html:56
#: users/templates/users/reset_password.html:52 #: users/templates/users/reset_password.html:52
#: users/templates/users/user_create.html:11 #: users/templates/users/user_create.html:11
...@@ -661,7 +661,7 @@ msgstr "其它" ...@@ -661,7 +661,7 @@ msgstr "其它"
#: assets/templates/assets/asset_group_create.html:16 #: assets/templates/assets/asset_group_create.html:16
#: assets/templates/assets/asset_update.html:55 #: assets/templates/assets/asset_update.html:55
#: assets/templates/assets/cluster_create_update.html:54 #: assets/templates/assets/cluster_create_update.html:54
#: common/templates/common/basic_setting.html:56 #: common/templates/common/basic_setting.html:55
#: common/templates/common/email_setting.html:56 #: common/templates/common/email_setting.html:56
#: common/templates/common/ldap_setting.html:56 #: common/templates/common/ldap_setting.html:56
#: perms/templates/perms/asset_permission_create_update.html:67 #: perms/templates/perms/asset_permission_create_update.html:67
...@@ -681,10 +681,10 @@ msgstr "重置" ...@@ -681,10 +681,10 @@ msgstr "重置"
#: assets/templates/assets/asset_bulk_update.html:24 #: assets/templates/assets/asset_bulk_update.html:24
#: assets/templates/assets/asset_create.html:41 #: assets/templates/assets/asset_create.html:41
#: assets/templates/assets/asset_group_create.html:17 #: assets/templates/assets/asset_group_create.html:17
#: assets/templates/assets/asset_list.html:55 #: assets/templates/assets/asset_list.html:53
#: assets/templates/assets/asset_update.html:56 #: assets/templates/assets/asset_update.html:56
#: assets/templates/assets/cluster_create_update.html:55 #: assets/templates/assets/cluster_create_update.html:55
#: common/templates/common/basic_setting.html:57 #: common/templates/common/basic_setting.html:56
#: common/templates/common/email_setting.html:57 #: common/templates/common/email_setting.html:57
#: common/templates/common/ldap_setting.html:57 #: common/templates/common/ldap_setting.html:57
#: perms/templates/perms/asset_permission_create_update.html:68 #: perms/templates/perms/asset_permission_create_update.html:68
...@@ -726,8 +726,8 @@ msgstr "资产列表" ...@@ -726,8 +726,8 @@ msgstr "资产列表"
#: assets/templates/assets/asset_detail.html:24 #: assets/templates/assets/asset_detail.html:24
#: assets/templates/assets/asset_group_detail.html:18 #: assets/templates/assets/asset_group_detail.html:18
#: assets/templates/assets/asset_group_detail.html:177 #: assets/templates/assets/asset_group_detail.html:177
#: assets/templates/assets/asset_group_list.html:42 #: assets/templates/assets/asset_group_list.html:38
#: assets/templates/assets/asset_list.html:95 #: assets/templates/assets/asset_list.html:98
#: assets/templates/assets/cluster_assets.html:170 #: assets/templates/assets/cluster_assets.html:170
#: assets/templates/assets/cluster_detail.html:25 #: assets/templates/assets/cluster_detail.html:25
#: assets/templates/assets/cluster_list.html:43 #: assets/templates/assets/cluster_list.html:43
...@@ -750,8 +750,8 @@ msgstr "更新" ...@@ -750,8 +750,8 @@ msgstr "更新"
#: assets/templates/assets/admin_user_list.html:84 #: assets/templates/assets/admin_user_list.html:84
#: assets/templates/assets/asset_detail.html:28 #: assets/templates/assets/asset_detail.html:28
#: assets/templates/assets/asset_group_detail.html:22 #: assets/templates/assets/asset_group_detail.html:22
#: assets/templates/assets/asset_group_list.html:43 #: assets/templates/assets/asset_group_list.html:39
#: assets/templates/assets/asset_list.html:96 #: assets/templates/assets/asset_list.html:99
#: assets/templates/assets/cluster_detail.html:29 #: assets/templates/assets/cluster_detail.html:29
#: assets/templates/assets/cluster_list.html:44 #: assets/templates/assets/cluster_list.html:44
#: assets/templates/assets/system_user_detail.html:30 #: assets/templates/assets/system_user_detail.html:30
...@@ -776,7 +776,6 @@ msgstr "资产列表" ...@@ -776,7 +776,6 @@ msgstr "资产列表"
#: assets/templates/assets/admin_user_assets.html:62 #: assets/templates/assets/admin_user_assets.html:62
#: assets/templates/assets/asset_group_detail.html:53 #: assets/templates/assets/asset_group_detail.html:53
#: assets/templates/assets/asset_list.html:34
#: assets/templates/assets/cluster_assets.html:54 #: assets/templates/assets/cluster_assets.html:54
#: assets/templates/assets/user_asset_list.html:22 #: assets/templates/assets/user_asset_list.html:22
#: users/templates/users/login_log_list.html:50 #: users/templates/users/login_log_list.html:50
...@@ -786,7 +785,7 @@ msgstr "类型" ...@@ -786,7 +785,7 @@ msgstr "类型"
#: assets/templates/assets/admin_user_assets.html:63 #: assets/templates/assets/admin_user_assets.html:63
#: assets/templates/assets/admin_user_list.html:25 #: assets/templates/assets/admin_user_list.html:25
#: assets/templates/assets/asset_detail.html:376 #: assets/templates/assets/asset_detail.html:376
#: assets/templates/assets/asset_list.html:38 #: assets/templates/assets/asset_list.html:36
#: assets/templates/assets/system_user_asset.html:55 #: assets/templates/assets/system_user_asset.html:55
#: assets/templates/assets/system_user_list.html:27 #: assets/templates/assets/system_user_list.html:27
msgid "Reachable" msgid "Reachable"
...@@ -827,8 +826,8 @@ msgstr "使用集群管理用户" ...@@ -827,8 +826,8 @@ msgstr "使用集群管理用户"
#: assets/templates/assets/admin_user_detail.html:101 #: assets/templates/assets/admin_user_detail.html:101
#: assets/templates/assets/asset_detail.html:230 #: assets/templates/assets/asset_detail.html:230
#: assets/templates/assets/asset_group_list.html:85 #: assets/templates/assets/asset_group_list.html:81
#: assets/templates/assets/asset_list.html:214 #: assets/templates/assets/asset_list.html:220
#: assets/templates/assets/cluster_assets.html:104 #: assets/templates/assets/cluster_assets.html:104
#: assets/templates/assets/cluster_list.html:89 #: assets/templates/assets/cluster_list.html:89
#: assets/templates/assets/system_user_detail.html:164 #: assets/templates/assets/system_user_detail.html:164
...@@ -859,7 +858,7 @@ msgstr "比例" ...@@ -859,7 +858,7 @@ msgstr "比例"
#: assets/templates/assets/admin_user_list.html:29 #: assets/templates/assets/admin_user_list.html:29
#: assets/templates/assets/asset_group_detail.html:55 #: assets/templates/assets/asset_group_detail.html:55
#: assets/templates/assets/asset_group_list.html:18 #: assets/templates/assets/asset_group_list.html:18
#: assets/templates/assets/asset_list.html:39 #: assets/templates/assets/asset_list.html:37
#: assets/templates/assets/cluster_assets.html:56 #: assets/templates/assets/cluster_assets.html:56
#: assets/templates/assets/cluster_list.html:23 #: assets/templates/assets/cluster_list.html:23
#: assets/templates/assets/system_user_list.html:31 #: assets/templates/assets/system_user_list.html:31
...@@ -909,7 +908,7 @@ msgid "Quick modify" ...@@ -909,7 +908,7 @@ msgid "Quick modify"
msgstr "快速修改" msgstr "快速修改"
#: assets/templates/assets/asset_detail.html:175 #: assets/templates/assets/asset_detail.html:175
#: assets/templates/assets/asset_list.html:37 #: assets/templates/assets/asset_list.html:35
#: assets/templates/assets/user_asset_list.html:25 perms/models.py:20 #: assets/templates/assets/user_asset_list.html:25 perms/models.py:20
#: perms/templates/perms/asset_permission_create_update.html:47 #: perms/templates/perms/asset_permission_create_update.html:47
#: perms/templates/perms/asset_permission_detail.html:116 #: perms/templates/perms/asset_permission_detail.html:116
...@@ -970,8 +969,8 @@ msgstr "移除" ...@@ -970,8 +969,8 @@ msgstr "移除"
msgid "Create asset group" msgid "Create asset group"
msgstr "创建资产组" msgstr "创建资产组"
#: assets/templates/assets/asset_group_list.html:80 #: assets/templates/assets/asset_group_list.html:76
#: assets/templates/assets/asset_list.html:209 #: assets/templates/assets/asset_list.html:215
#: assets/templates/assets/cluster_list.html:84 #: assets/templates/assets/cluster_list.html:84
#: assets/templates/assets/system_user_list.html:129 #: assets/templates/assets/system_user_list.html:129
#: users/templates/users/user_detail.html:333 #: users/templates/users/user_detail.html:333
...@@ -981,29 +980,29 @@ msgstr "创建资产组" ...@@ -981,29 +980,29 @@ msgstr "创建资产组"
msgid "Are you sure?" msgid "Are you sure?"
msgstr "你确认吗?" msgstr "你确认吗?"
#: assets/templates/assets/asset_group_list.html:81 #: assets/templates/assets/asset_group_list.html:77
#: users/templates/users/user_group_list.html:78 #: users/templates/users/user_group_list.html:78
msgid "This will delete the selected groups !!!" msgid "This will delete the selected groups !!!"
msgstr "删除选择组" msgstr "删除选择组"
#: assets/templates/assets/asset_group_list.html:89 #: assets/templates/assets/asset_group_list.html:85
msgid "Group deleted" msgid "Group deleted"
msgstr "组已被删除" msgstr "组已被删除"
#: assets/templates/assets/asset_group_list.html:90 #: assets/templates/assets/asset_group_list.html:86
#: assets/templates/assets/asset_group_list.html:95 #: assets/templates/assets/asset_group_list.html:91
msgid "Group Delete" msgid "Group Delete"
msgstr "删除" msgstr "删除"
#: assets/templates/assets/asset_group_list.html:94 #: assets/templates/assets/asset_group_list.html:90
msgid "Group deleting failed." msgid "Group deleting failed."
msgstr "删除失败" msgstr "删除失败"
#: assets/templates/assets/asset_group_list.html:157 #: assets/templates/assets/asset_group_list.html:153
msgid "The selected asset groups has been updated successfully." msgid "The selected asset groups has been updated successfully."
msgstr "更新成功" msgstr "更新成功"
#: assets/templates/assets/asset_group_list.html:158 #: assets/templates/assets/asset_group_list.html:154
msgid "AssetGroup Updated" msgid "AssetGroup Updated"
msgstr "资产组更新" msgstr "资产组更新"
...@@ -1021,52 +1020,47 @@ msgstr "导出" ...@@ -1021,52 +1020,47 @@ msgstr "导出"
msgid "Create asset" msgid "Create asset"
msgstr "创建资产" msgstr "创建资产"
#: assets/templates/assets/asset_list.html:35 #: assets/templates/assets/asset_list.html:34
#: assets/templates/assets/user_asset_list.html:23
msgid "Env"
msgstr "环境"
#: assets/templates/assets/asset_list.html:36
#: assets/templates/assets/user_asset_list.html:24 #: assets/templates/assets/user_asset_list.html:24
msgid "Hardware" msgid "Hardware"
msgstr "硬件" msgstr "硬件"
#: assets/templates/assets/asset_list.html:48 #: assets/templates/assets/asset_list.html:46
#: users/templates/users/user_list.html:37 #: users/templates/users/user_list.html:37
msgid "Delete selected" msgid "Delete selected"
msgstr "批量删除" msgstr "批量删除"
#: assets/templates/assets/asset_list.html:49 #: assets/templates/assets/asset_list.html:47
#: users/templates/users/user_list.html:38 #: users/templates/users/user_list.html:38
msgid "Update selected" msgid "Update selected"
msgstr "批量更新" msgstr "批量更新"
#: assets/templates/assets/asset_list.html:50 #: assets/templates/assets/asset_list.html:48
#: users/templates/users/user_list.html:39 #: users/templates/users/user_list.html:39
msgid "Deactive selected" msgid "Deactive selected"
msgstr "禁用所选" msgstr "禁用所选"
#: assets/templates/assets/asset_list.html:51 #: assets/templates/assets/asset_list.html:49
#: users/templates/users/user_list.html:40 #: users/templates/users/user_list.html:40
msgid "Active selected" msgid "Active selected"
msgstr "激活所选" msgstr "激活所选"
#: assets/templates/assets/asset_list.html:210 #: assets/templates/assets/asset_list.html:216
msgid "This will delete the selected assets !!!" msgid "This will delete the selected assets !!!"
msgstr "删除选择资产" msgstr "删除选择资产"
# msgid "Deleted!" # msgid "Deleted!"
# msgstr "删除" # msgstr "删除"
#: assets/templates/assets/asset_list.html:218 #: assets/templates/assets/asset_list.html:224
msgid "Asset Deleted." msgid "Asset Deleted."
msgstr "已被删除" msgstr "已被删除"
#: assets/templates/assets/asset_list.html:219 #: assets/templates/assets/asset_list.html:225
#: assets/templates/assets/asset_list.html:224 #: assets/templates/assets/asset_list.html:230
msgid "Asset Delete" msgid "Asset Delete"
msgstr "删除" msgstr "删除"
#: assets/templates/assets/asset_list.html:223 #: assets/templates/assets/asset_list.html:229
msgid "Asset Deleting failed." msgid "Asset Deleting failed."
msgstr "删除失败" msgstr "删除失败"
...@@ -1202,6 +1196,10 @@ msgstr "删除系统用户" ...@@ -1202,6 +1196,10 @@ msgstr "删除系统用户"
msgid "System Users Deleting failed." msgid "System Users Deleting failed."
msgstr "系统用户删除失败" msgstr "系统用户删除失败"
#: assets/templates/assets/user_asset_list.html:23
msgid "Env"
msgstr "环境"
#: assets/templates/assets/user_asset_list.html:26 #: assets/templates/assets/user_asset_list.html:26
msgid "Connective" msgid "Connective"
msgstr "连接性" msgstr "连接性"
...@@ -1317,58 +1315,62 @@ msgstr "LDAP认证" ...@@ -1317,58 +1315,62 @@ msgstr "LDAP认证"
msgid "SMTP host" msgid "SMTP host"
msgstr "SMTP主机" msgstr "SMTP主机"
#: common/forms.py:84 #: common/forms.py:81
msgid "SMTP port" msgid "SMTP port"
msgstr "SMTP端口" msgstr "SMTP端口"
#: common/forms.py:86 #: common/forms.py:83
msgid "SMTP user" msgid "SMTP user"
msgstr "SMTP账号" msgstr "SMTP账号"
#: common/forms.py:89 #: common/forms.py:86
msgid "SMTP password" msgid "SMTP password"
msgstr "SMTP密码" msgstr "SMTP密码"
#: common/forms.py:90 #: common/forms.py:87
msgid "Some provider use token except password" msgid "Some provider use token except password"
msgstr "一些邮件提供商需要输入的是Token" msgstr "一些邮件提供商需要输入的是Token"
#: common/forms.py:93 common/forms.py:130 #: common/forms.py:90 common/forms.py:127
msgid "Use SSL" msgid "Use SSL"
msgstr "使用SSL" msgstr "使用SSL"
#: common/forms.py:94 #: common/forms.py:91
msgid "If SMTP port is 465, may be select" msgid "If SMTP port is 465, may be select"
msgstr "如果SMTP端口是465,通常需要启用SSL" msgstr "如果SMTP端口是465,通常需要启用SSL"
#: common/forms.py:97 #: common/forms.py:94
msgid "Use TLS" msgid "Use TLS"
msgstr "使用TLS" msgstr "使用TLS"
#: common/forms.py:98 #: common/forms.py:95
msgid "If SMTP port is 587, may be select" msgid "If SMTP port is 587, may be select"
msgstr "如果SMTP端口是587,通常需要启用TLS" msgstr "如果SMTP端口是587,通常需要启用TLS"
#: common/forms.py:104 #: common/forms.py:101
msgid "LDAP server" msgid "LDAP server"
msgstr "LDAP地址" msgstr "LDAP地址"
#: common/forms.py:107 #: common/forms.py:104
msgid "Bind DN" msgid "Bind DN"
msgstr "绑定DN" msgstr "绑定DN"
#: common/forms.py:114 #: common/forms.py:111
msgid "User OU" msgid "User OU"
msgstr "用户OU" msgstr "用户OU"
#: common/forms.py:117 #: common/forms.py:114
msgid "User search filter" msgid "User search filter"
msgstr "用户过滤器" msgstr "用户过滤器"
#: common/forms.py:120 #: common/forms.py:117
msgid "User attr map" msgid "User attr map"
msgstr "LDAP属性映射" msgstr "LDAP属性映射"
#: common/forms.py:130
msgid "Enable LDAP Auth"
msgstr "开启LDAP认证"
#: common/mixins.py:29 #: common/mixins.py:29
msgid "is discard" msgid "is discard"
msgstr "" msgstr ""
...@@ -1393,7 +1395,7 @@ msgstr "基本设置" ...@@ -1393,7 +1395,7 @@ msgstr "基本设置"
#: common/templates/common/basic_setting.html:18 #: common/templates/common/basic_setting.html:18
#: common/templates/common/email_setting.html:18 #: common/templates/common/email_setting.html:18
#: common/templates/common/ldap_setting.html:18 common/views.py:45 #: common/templates/common/ldap_setting.html:18 common/views.py:44
msgid "Email setting" msgid "Email setting"
msgstr "邮件设置" msgstr "邮件设置"
...@@ -1403,20 +1405,19 @@ msgstr "邮件设置" ...@@ -1403,20 +1405,19 @@ msgstr "邮件设置"
msgid "LDAP setting" msgid "LDAP setting"
msgstr "LDAP设置" msgstr "LDAP设置"
#: common/templates/common/basic_setting.html:55
#: common/templates/common/email_setting.html:55 #: common/templates/common/email_setting.html:55
#: common/templates/common/ldap_setting.html:55 #: common/templates/common/ldap_setting.html:55
msgid "Test connection" msgid "Test connection"
msgstr "测试连接" msgstr "测试连接"
#: common/views.py:17 common/views.py:44 common/views.py:69 #: common/views.py:17 common/views.py:43 common/views.py:69
#: templates/_nav.html:69 #: templates/_nav.html:69
msgid "Settings" msgid "Settings"
msgstr "系统设置" msgstr "系统设置"
#: common/views.py:30 common/views.py:55 common/views.py:80 #: common/views.py:28 common/views.py:54 common/views.py:82
msgid "Update setting successfully" msgid "Update setting successfully, please restart program"
msgstr "更新设置成功" msgstr "更新设置成功, 请手动重启程序"
#: ops/models.py:32 #: ops/models.py:32
msgid "Interval" msgid "Interval"
...@@ -1912,8 +1913,8 @@ msgid "Close" ...@@ -1912,8 +1913,8 @@ msgid "Close"
msgstr "关闭" msgstr "关闭"
#: templates/_nav.html:9 users/views/group.py:28 users/views/group.py:44 #: templates/_nav.html:9 users/views/group.py:28 users/views/group.py:44
#: users/views/group.py:62 users/views/group.py:79 users/views/login.py:194 #: users/views/group.py:62 users/views/group.py:79 users/views/login.py:197
#: users/views/login.py:243 users/views/user.py:57 users/views/user.py:72 #: users/views/login.py:246 users/views/user.py:57 users/views/user.py:72
#: users/views/user.py:91 users/views/user.py:147 users/views/user.py:304 #: users/views/user.py:91 users/views/user.py:147 users/views/user.py:304
#: users/views/user.py:318 users/views/user.py:355 users/views/user.py:377 #: users/views/user.py:318 users/views/user.py:355 users/views/user.py:377
msgid "Users" msgid "Users"
...@@ -2740,48 +2741,48 @@ msgstr "编辑用户组" ...@@ -2740,48 +2741,48 @@ msgstr "编辑用户组"
msgid "Please enable cookies and try again." msgid "Please enable cookies and try again."
msgstr "设置你的浏览器支持cookie" msgstr "设置你的浏览器支持cookie"
#: users/views/login.py:84 #: users/views/login.py:87
msgid "Logout success" msgid "Logout success"
msgstr "退出登录成功" msgstr "退出登录成功"
#: users/views/login.py:85 #: users/views/login.py:88
msgid "Logout success, return login page" msgid "Logout success, return login page"
msgstr "退出登录成功,返回到登录页面" msgstr "退出登录成功,返回到登录页面"
#: users/views/login.py:101 #: users/views/login.py:104
msgid "Email address invalid, please input again" msgid "Email address invalid, please input again"
msgstr "邮箱地址错误,重新输入" msgstr "邮箱地址错误,重新输入"
#: users/views/login.py:114 #: users/views/login.py:117
msgid "Send reset password message" msgid "Send reset password message"
msgstr "发送重置密码邮件" msgstr "发送重置密码邮件"
#: users/views/login.py:115 #: users/views/login.py:118
msgid "Send reset password mail success, login your mail box and follow it " msgid "Send reset password mail success, login your mail box and follow it "
msgstr "" msgstr ""
"发送重置邮件成功, 请登录邮箱查看, 按照提示操作 (如果没收到,请等待3-5分钟)" "发送重置邮件成功, 请登录邮箱查看, 按照提示操作 (如果没收到,请等待3-5分钟)"
#: users/views/login.py:129 #: users/views/login.py:132
msgid "Reset password success" msgid "Reset password success"
msgstr "重置密码成功" msgstr "重置密码成功"
#: users/views/login.py:130 #: users/views/login.py:133
msgid "Reset password success, return to login page" msgid "Reset password success, return to login page"
msgstr "重置密码成功,返回到登录页面" msgstr "重置密码成功,返回到登录页面"
#: users/views/login.py:147 users/views/login.py:160 #: users/views/login.py:150 users/views/login.py:163
msgid "Token invalid or expired" msgid "Token invalid or expired"
msgstr "Token错误或失效" msgstr "Token错误或失效"
#: users/views/login.py:156 #: users/views/login.py:159
msgid "Password not same" msgid "Password not same"
msgstr "密码不一致" msgstr "密码不一致"
#: users/views/login.py:194 #: users/views/login.py:197
msgid "First login" msgid "First login"
msgstr "首次登陆" msgstr "首次登陆"
#: users/views/login.py:244 #: users/views/login.py:247
msgid "Login log list" msgid "Login log list"
msgstr "登录日志" msgstr "登录日志"
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
from collections import OrderedDict from collections import OrderedDict
import copy
import logging import logging
import os import os
import uuid import uuid
...@@ -21,7 +20,8 @@ from .serializers import TerminalSerializer, StatusSerializer, \ ...@@ -21,7 +20,8 @@ from .serializers import TerminalSerializer, StatusSerializer, \
SessionSerializer, TaskSerializer, ReplaySerializer SessionSerializer, TaskSerializer, ReplaySerializer
from .hands import IsSuperUserOrAppUser, IsAppUser, \ from .hands import IsSuperUserOrAppUser, IsAppUser, \
IsSuperUserOrAppUserOrUserReadonly IsSuperUserOrAppUserOrUserReadonly
from .backends import get_terminal_command_store, SessionCommandSerializer from .backends import get_command_store, get_multi_command_store, \
SessionCommandSerializer
logger = logging.getLogger(__file__) logger = logging.getLogger(__file__)
...@@ -196,7 +196,8 @@ class CommandViewSet(viewsets.ViewSet): ...@@ -196,7 +196,8 @@ class CommandViewSet(viewsets.ViewSet):
} }
""" """
command_store = get_terminal_command_store() command_store = get_command_store()
multi_command_storage = get_multi_command_store()
serializer_class = SessionCommandSerializer serializer_class = SessionCommandSerializer
permission_classes = (IsSuperUserOrAppUser,) permission_classes = (IsSuperUserOrAppUser,)
...@@ -217,7 +218,7 @@ class CommandViewSet(viewsets.ViewSet): ...@@ -217,7 +218,7 @@ class CommandViewSet(viewsets.ViewSet):
return Response({"msg": msg}, status=401) return Response({"msg": msg}, status=401)
def list(self, request, *args, **kwargs): def list(self, request, *args, **kwargs):
queryset = list(self.command_store.all()) queryset = self.multi_command_storage.filter()
serializer = self.serializer_class(queryset, many=True) serializer = self.serializer_class(queryset, many=True)
return Response(serializer.data) return Response(serializer.data)
......
...@@ -3,7 +3,7 @@ from django.conf import settings ...@@ -3,7 +3,7 @@ from django.conf import settings
from .command.serializers import SessionCommandSerializer from .command.serializers import SessionCommandSerializer
TYPE_ENGINE_MAPPING = { TYPE_ENGINE_MAPPING = {
'elasticsearch': 'terminal.backends.command.db', 'elasticsearch': 'terminal.backends.command.es',
} }
...@@ -31,4 +31,10 @@ def get_terminal_command_store(): ...@@ -31,4 +31,10 @@ def get_terminal_command_store():
return storage_list return storage_list
def get_multi_command_store():
from .command.multi import CommandStore
storage_list = get_terminal_command_store().values()
storage = CommandStore(storage_list)
return storage
...@@ -73,7 +73,7 @@ class CommandStore(CommandBase): ...@@ -73,7 +73,7 @@ class CommandStore(CommandBase):
session=session, session=session,
) )
queryset = self.model.objects.filter(**filter_kwargs) queryset = self.model.objects.filter(**filter_kwargs)
return queryset return [command.to_dict() for command in queryset]
def count(self, date_from=None, date_to=None, def count(self, date_from=None, date_to=None,
user=None, asset=None, system_user=None, user=None, asset=None, system_user=None,
......
# -*- coding: utf-8 -*-
#
from jms_es_sdk import ESStore
from .base import CommandBase
class CommandStore(CommandBase, ESStore):
def __init__(self, params):
hosts = params.get('HOSTS', ['http://localhost'])
ESStore.__init__(self, hosts=hosts)
def save(self, command):
return ESStore.save(self, command)
def bulk_save(self, commands):
return ESStore.bulk_save(self, commands)
def filter(self, date_from=None, date_to=None,
user=None, asset=None, system_user=None,
input=None, session=None):
data = ESStore.filter(
self, date_from=date_from, date_to=date_to,
user=user, asset=asset, system_user=system_user,
input=input, session=session
)
return [item["_source"] for item in data["hits"] if item]
def count(self, date_from=None, date_to=None,
user=None, asset=None, system_user=None,
input=None, session=None):
amount = ESStore.count(
self, date_from=date_from, date_to=date_to,
user=user, asset=asset, system_user=system_user,
input=input, session=session
)
return amount
...@@ -33,5 +33,11 @@ class AbstractSessionCommand(models.Model): ...@@ -33,5 +33,11 @@ class AbstractSessionCommand(models.Model):
commands.append(command) commands.append(command)
return commands return commands
def to_dict(self):
d = {}
for field in self._meta.fields:
d[field.name] = getattr(self, field.name)
return d
def __str__(self): def __str__(self):
return self.input return self.input
# -*- coding: utf-8 -*-
#
from .base import CommandBase
class CommandStore(CommandBase):
def __init__(self, storage_list):
self.storage_list = storage_list
def filter(self, **kwargs):
queryset = []
for storage in self.storage_list:
queryset.extend(storage.filter(**kwargs))
return sorted(queryset, key=lambda command: command["timestamp"])
def count(self, **kwargs):
amount = 0
for storage in self.storage_list:
amount += storage.count(**kwargs)
return amount
def save(self, command):
pass
def bulk_save(self, commands):
pass
\ No newline at end of file
...@@ -11,10 +11,11 @@ from .backends.command.models import AbstractSessionCommand ...@@ -11,10 +11,11 @@ from .backends.command.models import AbstractSessionCommand
def get_all_command_storage(): def get_all_command_storage():
storage_choices = [] # storage_choices = []
from common.models import Setting
Setting.refresh_all_settings()
for k, v in settings.TERMINAL_COMMAND_STORAGE.items(): for k, v in settings.TERMINAL_COMMAND_STORAGE.items():
storage_choices.append((k, k)) yield (k, k)
return storage_choices
class Terminal(models.Model): class Terminal(models.Model):
......
...@@ -5,7 +5,7 @@ from django.utils import timezone ...@@ -5,7 +5,7 @@ from django.utils import timezone
from rest_framework import serializers from rest_framework import serializers
from .models import Terminal, Status, Session, Task from .models import Terminal, Status, Session, Task
from .backends import get_terminal_command_store from .backends import get_multi_command_store
class TerminalSerializer(serializers.ModelSerializer): class TerminalSerializer(serializers.ModelSerializer):
...@@ -43,14 +43,14 @@ class TerminalSerializer(serializers.ModelSerializer): ...@@ -43,14 +43,14 @@ class TerminalSerializer(serializers.ModelSerializer):
class SessionSerializer(serializers.ModelSerializer): class SessionSerializer(serializers.ModelSerializer):
command_amount = serializers.SerializerMethodField() command_amount = serializers.SerializerMethodField()
command_store = get_terminal_command_store() command_store = get_multi_command_store()
class Meta: class Meta:
model = Session model = Session
fields = '__all__' fields = '__all__'
def get_command_amount(self, obj): def get_command_amount(self, obj):
return len(self.command_store.filter(session=obj.session)) return self.command_store.count(session=str(obj.id))
class StatusSerializer(serializers.ModelSerializer): class StatusSerializer(serializers.ModelSerializer):
......
# ~*~ coding: utf-8 ~*~ # ~*~ coding: utf-8 ~*~
from django import template from django import template
from ..backends import get_terminal_command_store from ..backends import get_multi_command_store
register = template.Library() register = template.Library()
command_store_dict = get_terminal_command_store() command_store = get_multi_command_store()
@register.filter @register.filter
def get_session_command_amount(session_id): def get_session_command_amount(session_id):
amount = 0 return command_store.count(session=session_id)
for name, store in command_store_dict.items():
amount += store.count(session=str(session_id))
return amount
...@@ -9,10 +9,10 @@ from django.utils.translation import ugettext as _ ...@@ -9,10 +9,10 @@ from django.utils.translation import ugettext as _
from common.mixins import DatetimeSearchMixin from common.mixins import DatetimeSearchMixin
from ..models import Command from ..models import Command
from .. import utils from .. import utils
from ..backends import get_terminal_command_store from ..backends import get_multi_command_store
__all__ = ['CommandListView'] __all__ = ['CommandListView']
command_store_list = get_terminal_command_store() common_storage = get_multi_command_store()
class CommandListView(DatetimeSearchMixin, ListView): class CommandListView(DatetimeSearchMixin, ListView):
...@@ -39,10 +39,7 @@ class CommandListView(DatetimeSearchMixin, ListView): ...@@ -39,10 +39,7 @@ class CommandListView(DatetimeSearchMixin, ListView):
filter_kwargs['system_user'] = self.system_user filter_kwargs['system_user'] = self.system_user
if self.command: if self.command:
filter_kwargs['input'] = self.command filter_kwargs['input'] = self.command
queryset = [] queryset = common_storage.filter(**filter_kwargs)
for store in command_store_list:
queryset.extend(store.filter(**filter_kwargs))
queryset = sorted(queryset, key=lambda c: c.timestamp, reverse=True)
return queryset return queryset
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
......
...@@ -10,7 +10,7 @@ from django.conf import settings ...@@ -10,7 +10,7 @@ from django.conf import settings
from users.utils import AdminUserRequiredMixin from users.utils import AdminUserRequiredMixin
from common.mixins import DatetimeSearchMixin from common.mixins import DatetimeSearchMixin
from ..models import Session, Command, Terminal from ..models import Session, Command, Terminal
from ..backends import get_terminal_command_store from ..backends import get_multi_command_store
from .. import utils from .. import utils
...@@ -19,7 +19,7 @@ __all__ = [ ...@@ -19,7 +19,7 @@ __all__ = [
'SessionDetailView', 'SessionDetailView',
] ]
command_store = get_terminal_command_store() command_store = get_multi_command_store()
class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView): class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView):
......
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