Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
b237cbb2
Commit
b237cbb2
authored
May 24, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:jumpserver/jumpserver into dev
parents
9b5b48dd
b7eac837
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
613 additions
and
275 deletions
+613
-275
const.py
apps/applications/const.py
+1
-1
remote_app.py
apps/applications/forms/remote_app.py
+21
-0
remote_app_create_update.html
...ions/templates/applications/remote_app_create_update.html
+41
-8
ldap.py
apps/authentication/backends/ldap.py
+16
-9
settings.py
apps/jumpserver/settings.py
+6
-0
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+262
-160
user_permission.py
apps/perms/api/user_permission.py
+1
-0
api.py
apps/settings/api.py
+4
-4
forms.py
apps/settings/forms.py
+23
-0
_ldap_list_users_modal.html
apps/settings/templates/settings/_ldap_list_users_modal.html
+3
-0
basic_setting.html
apps/settings/templates/settings/basic_setting.html
+3
-0
email_content_setting.html
apps/settings/templates/settings/email_content_setting.html
+72
-0
email_setting.html
apps/settings/templates/settings/email_setting.html
+3
-0
ldap_setting.html
apps/settings/templates/settings/ldap_setting.html
+8
-5
security_setting.html
apps/settings/templates/settings/security_setting.html
+3
-0
terminal_setting.html
apps/settings/templates/settings/terminal_setting.html
+3
-0
view_urls.py
apps/settings/urls/view_urls.py
+1
-0
utils.py
apps/settings/utils.py
+61
-64
views.py
apps/settings/views.py
+27
-1
utils.py
apps/users/utils.py
+54
-23
No files found.
apps/applications/const.py
View file @
b237cbb2
...
...
@@ -28,7 +28,7 @@ REMOTE_APP_TYPE_CHOICES = (
(
_
(
'Virtualization tools'
),
(
(
REMOTE_APP_TYPE_VMWARE_CLIENT
,
'
VMwa
re Client'
),
(
REMOTE_APP_TYPE_VMWARE_CLIENT
,
'
vSphe
re Client'
),
)
),
(
REMOTE_APP_TYPE_CUSTOM
,
_
(
'Custom'
)),
...
...
apps/applications/forms/remote_app.py
View file @
b237cbb2
...
...
@@ -8,6 +8,7 @@ from orgs.mixins import OrgModelForm
from
assets.models
import
Asset
,
SystemUser
from
..models
import
RemoteApp
from
..
import
const
__all__
=
[
...
...
@@ -109,3 +110,23 @@ class RemoteAppCreateUpdateForm(RemoteAppTypeForms, OrgModelForm):
})
}
def
_clean_params
(
self
):
app_type
=
self
.
data
.
get
(
'type'
)
fields
=
const
.
REMOTE_APP_TYPE_MAP_FIELDS
.
get
(
app_type
,
[])
params
=
{}
for
field
in
fields
:
name
=
field
[
'name'
]
value
=
self
.
cleaned_data
[
name
]
params
.
update
({
name
:
value
})
return
params
def
_save_params
(
self
,
instance
):
params
=
self
.
_clean_params
()
instance
.
params
=
params
instance
.
save
()
return
instance
def
save
(
self
,
commit
=
True
):
instance
=
super
()
.
save
(
commit
=
commit
)
instance
=
self
.
_save_params
(
instance
)
return
instance
apps/applications/templates/applications/remote_app_create_update.html
View file @
b237cbb2
...
...
@@ -64,28 +64,60 @@
{% block custom_foot_js %}
<script
type=
"text/javascript"
>
var
type_id
=
'#'
+
'{{ form.type.id_for_label }}'
;
var
app_type_id
=
'#'
+
'{{ form.type.id_for_label }}'
;
var
app_path_id
=
'#'
+
'{{ form.path.id_for_label }}'
;
var
all_type_fields
=
[
'.chrome-fields'
,
'.mysql_workbench-fields'
,
'.vmware_client-fields'
,
'.custom-fields'
];
function
appTypeChange
(){
var
app_type_map_default_fields_value
=
{
'chrome'
:
{
'app_path'
:
'C:
\\
Program Files (x86)
\\
Google
\\
Chrome
\\
Application
\\
chrome.exe'
},
'mysql_workbench'
:
{
'app_path'
:
'C:
\\
Program Files
\\
MySQL
\\
MySQL Workbench 8.0 CE
\\
MySQLWorkbench.exe'
},
'vmware_client'
:
{
'app_path'
:
'C:
\\
Program Files (x86)
\\
VMware
\\
Infrastructure
\\
Virtual Infrastructure Client
\\
Launcher
\\
VpxClient.exe'
},
'custom'
:
{
'app_path'
:
''
}
};
function
getAppType
(){
return
$
(
app_type_id
+
" option:selected"
).
val
();
}
function
initialDefaultValue
(){
var
app_type
=
getAppType
();
var
app_path
=
$
(
app_path_id
).
val
();
if
(
app_path
){
app_type_map_default_fields_value
[
app_type
][
'app_path'
]
=
app_path
}
}
function
setDefaultValue
(){
// 设置类型相关字段的默认值
var
app_type
=
getAppType
();
var
app_path
=
app_type_map_default_fields_value
[
app_type
][
'app_path'
];
$
(
app_path_id
).
val
(
app_path
)
}
function
hiddenFields
(){
var
app_type
=
getAppType
();
$
.
each
(
all_type_fields
,
function
(
index
,
value
){
$
(
value
).
addClass
(
'hidden'
)
});
var
type
=
$
(
type_id
+
" option:selected"
).
val
();
$
(
'.'
+
type
+
'-fields'
).
removeClass
(
'hidden'
);
$
(
'.'
+
app_type
+
'-fields'
).
removeClass
(
'hidden'
);
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
({
closeOnSelect
:
true
});
appTypeChange
()
});
initialDefaultValue
();
hiddenFields
();
setDefaultValue
();
})
.
on
(
'change'
,
type_id
,
function
(){
appTypeChange
();
.
on
(
'change'
,
app_type_id
,
function
(){
hiddenFields
();
setDefaultValue
();
});
</script>
{% endblock %}
\ No newline at end of file
apps/authentication/backends/ldap.py
View file @
b237cbb2
...
...
@@ -7,6 +7,8 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from
django_auth_ldap.backend
import
_LDAPUser
,
LDAPBackend
from
django_auth_ldap.config
import
_LDAPConfig
,
LDAPSearch
,
LDAPSearchUnion
from
users.utils
import
construct_user_email
logger
=
_LDAPConfig
.
get_logger
()
...
...
@@ -86,13 +88,18 @@ class LDAPUser(_LDAPUser):
return
user_dn
def
_populate_user_from_attributes
(
self
):
super
()
.
_populate_user_from_attributes
()
if
not
hasattr
(
self
.
_user
,
'email'
)
or
'@'
not
in
self
.
_user
.
email
:
if
'@'
not
in
self
.
_user
.
username
:
email
=
'{}@{}'
.
format
(
self
.
_user
.
username
,
settings
.
EMAIL_SUFFIX
)
for
field
,
attr
in
self
.
settings
.
USER_ATTR_MAP
.
items
():
try
:
value
=
self
.
attrs
[
attr
][
0
]
except
LookupError
:
logger
.
warning
(
"{} does not have a value for the attribute {}"
.
format
(
self
.
dn
,
attr
))
else
:
email
=
self
.
_user
.
username
setattr
(
self
.
_user
,
'email'
,
email
)
if
not
hasattr
(
self
.
_user
,
field
):
continue
if
isinstance
(
getattr
(
self
.
_user
,
field
),
bool
):
value
=
value
.
lower
()
in
[
'true'
,
'1'
]
setattr
(
self
.
_user
,
field
,
value
)
email
=
getattr
(
self
.
_user
,
'email'
,
''
)
email
=
construct_user_email
(
email
,
self
.
_user
.
username
)
setattr
(
self
.
_user
,
'email'
,
email
)
apps/jumpserver/settings.py
View file @
b237cbb2
...
...
@@ -357,6 +357,12 @@ EMAIL_USE_SSL = False
EMAIL_USE_TLS
=
False
EMAIL_SUBJECT_PREFIX
=
'[JMS] '
#Email custom content
EMAIL_CUSTOM_USER_CREATED_SUBJECT
=
''
EMAIL_CUSTOM_USER_CREATED_HONORIFIC
=
''
EMAIL_CUSTOM_USER_CREATED_BODY
=
''
EMAIL_CUSTOM_USER_CREATED_SIGNATURE
=
''
REST_FRAMEWORK
=
{
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
b237cbb2
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
b237cbb2
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-2
1 21:09
+0800\n"
"POT-Creation-Date: 2019-05-2
4 12:02
+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -33,45 +33,45 @@ msgstr "虚拟化工具"
msgid "Custom"
msgstr "自定义"
#: applications/forms/remote_app.py:2
0
#: applications/forms/remote_app.py:2
1
msgid "Target URL"
msgstr "目标URL"
#: applications/forms/remote_app.py:2
3 applications/forms/remote_app.py:52
#: applications/forms/remote_app.py:6
8
#: applications/forms/remote_app.py:2
4 applications/forms/remote_app.py:53
#: applications/forms/remote_app.py:6
9
msgid "Login username"
msgstr "登录账号"
#: applications/forms/remote_app.py:2
7 applications/forms/remote_app.py:56
#: applications/forms/remote_app.py:7
2
#: applications/forms/remote_app.py:2
8 applications/forms/remote_app.py:57
#: applications/forms/remote_app.py:7
3
msgid "Login password"
msgstr "登录密码"
#: applications/forms/remote_app.py:3
3
#: applications/forms/remote_app.py:3
4
msgid "Database IP"
msgstr "数据库IP"
#: applications/forms/remote_app.py:3
6
#: applications/forms/remote_app.py:3
7
msgid "Database name"
msgstr "数据库名"
#: applications/forms/remote_app.py:
39
#: applications/forms/remote_app.py:
40
msgid "Database username"
msgstr "数据库账号"
#: applications/forms/remote_app.py:4
3
#: applications/forms/remote_app.py:4
4
msgid "Database password"
msgstr "数据库密码"
#: applications/forms/remote_app.py:
49 applications/forms/remote_app.py:65
#: applications/forms/remote_app.py:
50 applications/forms/remote_app.py:66
msgid "Target address"
msgstr "目标地址"
#: applications/forms/remote_app.py:6
2
#: applications/forms/remote_app.py:6
3
msgid "Operating parameter"
msgstr "运行参数"
#: applications/forms/remote_app.py:10
5
applications/models/remote_app.py:23
#: applications/forms/remote_app.py:10
6
applications/models/remote_app.py:23
#: applications/templates/applications/remote_app_detail.html:57
#: applications/templates/applications/remote_app_list.html:22
#: applications/templates/applications/user_remote_app_list.html:18
...
...
@@ -101,12 +101,12 @@ msgstr "运行参数"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_execution_subtask_list.html:13
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:14
#: xpack/plugins/cloud/models.py:187
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
3
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
5
#: xpack/plugins/orgs/templates/orgs/org_list.html:16
msgid "Asset"
msgstr "资产"
#: applications/forms/remote_app.py:10
8
applications/models/remote_app.py:27
#: applications/forms/remote_app.py:10
9
applications/models/remote_app.py:27
#: applications/templates/applications/remote_app_detail.html:61
#: applications/templates/applications/remote_app_list.html:23
#: applications/templates/applications/user_remote_app_list.html:19
...
...
@@ -161,8 +161,8 @@ msgstr "系统用户"
#: settings/templates/settings/_ldap_list_users_modal.html:38
#: settings/templates/settings/command_storage_create.html:41
#: settings/templates/settings/replay_storage_create.html:44
#: settings/templates/settings/terminal_setting.html:8
0
#: settings/templates/settings/terminal_setting.html:10
2
terminal/models.py:22
#: settings/templates/settings/terminal_setting.html:8
3
#: settings/templates/settings/terminal_setting.html:10
5
terminal/models.py:22
#: terminal/models.py:241 terminal/templates/terminal/terminal_detail.html:43
#: terminal/templates/terminal/terminal_list.html:29 users/models/group.py:14
#: users/models/user.py:61 users/templates/users/_select_user_modal.html:13
...
...
@@ -177,9 +177,9 @@ msgstr "系统用户"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:61
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:12
#: xpack/plugins/cloud/models.py:49 xpack/plugins/cloud/models.py:119
#: xpack/plugins/cloud/templates/cloud/account_detail.html:5
0
#: xpack/plugins/cloud/templates/cloud/account_detail.html:5
2
#: xpack/plugins/cloud/templates/cloud/account_list.html:12
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:5
3
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:5
5
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:12
#: xpack/plugins/orgs/templates/orgs/org_detail.html:52
#: xpack/plugins/orgs/templates/orgs/org_list.html:12
...
...
@@ -224,6 +224,8 @@ msgstr "参数"
msgid "Created by"
msgstr "创建者"
# msgid "Created by"
# msgstr "创建者"
#: applications/models/remote_app.py:46
#: applications/templates/applications/remote_app_detail.html:73
#: assets/models/asset.py:110 assets/models/cluster.py:26
...
...
@@ -242,12 +244,14 @@ msgstr "创建者"
#: users/templates/users/user_group_detail.html:63
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:105
#: xpack/plugins/cloud/models.py:56 xpack/plugins/cloud/models.py:128
#: xpack/plugins/cloud/templates/cloud/account_detail.html:6
6
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:7
7
#: xpack/plugins/cloud/templates/cloud/account_detail.html:6
8
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:7
9
#: xpack/plugins/orgs/templates/orgs/org_detail.html:60
msgid "Date created"
msgstr "创建日期"
# msgid "Date created"
# msgstr "创建日期"
#: applications/models/remote_app.py:49
#: applications/templates/applications/remote_app_detail.html:81
#: applications/templates/applications/remote_app_list.html:24
...
...
@@ -282,9 +286,9 @@ msgstr "创建日期"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:117
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:19
#: xpack/plugins/cloud/models.py:54 xpack/plugins/cloud/models.py:125
#: xpack/plugins/cloud/templates/cloud/account_detail.html:7
0
#: xpack/plugins/cloud/templates/cloud/account_detail.html:7
2
#: xpack/plugins/cloud/templates/cloud/account_list.html:15
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:
69
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:
71
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:16
#: xpack/plugins/orgs/templates/orgs/org_detail.html:64
#: xpack/plugins/orgs/templates/orgs/org_list.html:22
...
...
@@ -315,13 +319,14 @@ msgstr "远程应用"
#: assets/templates/assets/label_create_update.html:18
#: perms/templates/perms/asset_permission_create_update.html:83
#: perms/templates/perms/remote_app_permission_create_update.html:83
#: settings/templates/settings/basic_setting.html:6
1
#: settings/templates/settings/basic_setting.html:6
4
#: settings/templates/settings/command_storage_create.html:79
#: settings/templates/settings/email_setting.html:62
#: settings/templates/settings/ldap_setting.html:61
#: settings/templates/settings/email_content_setting.html:54
#: settings/templates/settings/email_setting.html:65
#: settings/templates/settings/ldap_setting.html:64
#: settings/templates/settings/replay_storage_create.html:152
#: settings/templates/settings/security_setting.html:7
0
#: settings/templates/settings/terminal_setting.html:
68
#: settings/templates/settings/security_setting.html:7
3
#: settings/templates/settings/terminal_setting.html:
71
#: terminal/templates/terminal/terminal_update.html:45
#: users/templates/users/_user.html:50
#: users/templates/users/user_bulk_update.html:23
...
...
@@ -353,13 +358,14 @@ msgstr "重置"
#: audits/templates/audits/login_log_list.html:89
#: perms/templates/perms/asset_permission_create_update.html:84
#: perms/templates/perms/remote_app_permission_create_update.html:84
#: settings/templates/settings/basic_setting.html:6
2
#: settings/templates/settings/basic_setting.html:6
5
#: settings/templates/settings/command_storage_create.html:80
#: settings/templates/settings/email_setting.html:63
#: settings/templates/settings/ldap_setting.html:64
#: settings/templates/settings/email_content_setting.html:55
#: settings/templates/settings/email_setting.html:66
#: settings/templates/settings/ldap_setting.html:67
#: settings/templates/settings/replay_storage_create.html:153
#: settings/templates/settings/security_setting.html:7
1
#: settings/templates/settings/terminal_setting.html:7
0
#: settings/templates/settings/security_setting.html:7
4
#: settings/templates/settings/terminal_setting.html:7
3
#: terminal/templates/terminal/command_list.html:103
#: terminal/templates/terminal/session_list.html:126
#: terminal/templates/terminal/terminal_update.html:46
...
...
@@ -437,11 +443,11 @@ msgstr "详情"
#: users/templates/users/user_profile.html:187
#: users/templates/users/user_profile.html:196
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:29
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
5
#: xpack/plugins/cloud/templates/cloud/account_detail.html:2
3
#: xpack/plugins/cloud/templates/cloud/account_list.html:3
9
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
4
#: xpack/plugins/cloud/templates/cloud/account_detail.html:2
5
#: xpack/plugins/cloud/templates/cloud/account_list.html:3
8
#: xpack/plugins/orgs/templates/orgs/org_detail.html:25
#: xpack/plugins/orgs/templates/orgs/org_list.html:8
7
#: xpack/plugins/orgs/templates/orgs/org_list.html:8
5
msgid "Update"
msgstr "更新"
...
...
@@ -466,8 +472,8 @@ msgstr "更新"
#: perms/templates/perms/asset_permission_list.html:182
#: perms/templates/perms/remote_app_permission_detail.html:34
#: perms/templates/perms/remote_app_permission_list.html:60
#: settings/templates/settings/terminal_setting.html:9
0
#: settings/templates/settings/terminal_setting.html:11
2
#: settings/templates/settings/terminal_setting.html:9
3
#: settings/templates/settings/terminal_setting.html:11
5
#: terminal/templates/terminal/terminal_list.html:74
#: users/templates/users/user_detail.html:30
#: users/templates/users/user_group_detail.html:32
...
...
@@ -475,13 +481,13 @@ msgstr "更新"
#: users/templates/users/user_list.html:104
#: users/templates/users/user_list.html:108
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:33
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
7
#: xpack/plugins/cloud/templates/cloud/account_detail.html:2
7
#: xpack/plugins/cloud/templates/cloud/account_list.html:4
1
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:3
0
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
5
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
6
#: xpack/plugins/cloud/templates/cloud/account_detail.html:2
9
#: xpack/plugins/cloud/templates/cloud/account_list.html:4
0
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:3
2
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
4
#: xpack/plugins/orgs/templates/orgs/org_detail.html:29
#: xpack/plugins/orgs/templates/orgs/org_list.html:8
9
#: xpack/plugins/orgs/templates/orgs/org_list.html:8
7
msgid "Delete"
msgstr "删除"
...
...
@@ -528,8 +534,8 @@ msgstr "创建远程应用"
#: perms/templates/perms/asset_permission_list.html:60
#: perms/templates/perms/asset_permission_list.html:134
#: perms/templates/perms/remote_app_permission_list.html:19
#: settings/templates/settings/terminal_setting.html:8
2
#: settings/templates/settings/terminal_setting.html:10
4
#: settings/templates/settings/terminal_setting.html:8
5
#: settings/templates/settings/terminal_setting.html:10
7
#: terminal/templates/terminal/session_list.html:81
#: terminal/templates/terminal/terminal_list.html:36
#: users/templates/users/user_group_list.html:38
...
...
@@ -618,7 +624,7 @@ msgstr "节点管理"
#: assets/models/cluster.py:19 assets/models/user.py:91
#: assets/templates/assets/asset_detail.html:80 templates/_nav.html:24
#: xpack/plugins/cloud/models.py:124
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:6
5
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:6
7
#: xpack/plugins/orgs/templates/orgs/org_list.html:18
msgid "Admin user"
msgstr "管理用户"
...
...
@@ -655,8 +661,8 @@ msgstr "网域"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_execution_list.html:55
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:15
#: xpack/plugins/cloud/models.py:123
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:6
1
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
4
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:6
3
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
6
msgid "Node"
msgstr "节点"
...
...
@@ -1069,8 +1075,8 @@ msgstr "过滤器"
#: perms/templates/perms/remote_app_permission_remote_app.html:54
#: settings/templates/settings/command_storage_create.html:31
#: settings/templates/settings/replay_storage_create.html:31
#: settings/templates/settings/terminal_setting.html:8
1
#: settings/templates/settings/terminal_setting.html:10
3
#: settings/templates/settings/terminal_setting.html:8
4
#: settings/templates/settings/terminal_setting.html:10
6
msgid "Type"
msgstr "类型"
...
...
@@ -1382,7 +1388,7 @@ msgstr "需要二次认证来查看账号信息"
#: assets/templates/assets/system_user_asset.html:112
#: assets/templates/assets/system_user_detail.html:182
#: assets/templates/assets/system_user_list.html:168
#: settings/templates/settings/terminal_setting.html:16
5
#: settings/templates/settings/terminal_setting.html:16
8
#: templates/_modal.html:23 terminal/templates/terminal/session_detail.html:108
#: users/templates/users/user_detail.html:388
#: users/templates/users/user_detail.html:414
...
...
@@ -1409,7 +1415,7 @@ msgstr "获取认证信息错误"
#: assets/templates/assets/_asset_user_view_auth_modal.html:139
#: assets/templates/assets/_user_asset_detail_modal.html:23
#: settings/templates/settings/_ldap_list_users_modal.html:9
6
#: settings/templates/settings/_ldap_list_users_modal.html:9
9
#: templates/_modal.html:22
msgid "Close"
msgstr "关闭"
...
...
@@ -1578,7 +1584,7 @@ msgstr "导出"
#: assets/templates/assets/admin_user_list.html:24
#: assets/templates/assets/asset_list.html:81
#: assets/templates/assets/system_user_list.html:28
#: settings/templates/settings/_ldap_list_users_modal.html:
97
#: settings/templates/settings/_ldap_list_users_modal.html:
100
#: users/templates/users/user_group_list.html:15
#: users/templates/users/user_list.html:15
#: xpack/plugins/license/templates/license/license_detail.html:110
...
...
@@ -1799,7 +1805,7 @@ msgstr "删除选择资产"
#: assets/templates/assets/asset_list.html:698
#: assets/templates/assets/system_user_list.html:166
#: settings/templates/settings/terminal_setting.html:16
3
#: settings/templates/settings/terminal_setting.html:16
6
#: users/templates/users/user_detail.html:386
#: users/templates/users/user_detail.html:412
#: users/templates/users/user_detail.html:480
...
...
@@ -1903,8 +1909,8 @@ msgstr "创建网关"
#: assets/templates/assets/domain_gateway_list.html:99
#: assets/templates/assets/domain_gateway_list.html:101
#: settings/templates/settings/email_setting.html:6
1
#: settings/templates/settings/ldap_setting.html:6
2
#: settings/templates/settings/email_setting.html:6
4
#: settings/templates/settings/ldap_setting.html:6
5
msgid "Test connection"
msgstr "测试连接"
...
...
@@ -2227,7 +2233,7 @@ msgstr "原因"
#: audits/models.py:101 audits/templates/audits/login_log_list.html:58
#: xpack/plugins/cloud/models.py:171 xpack/plugins/cloud/models.py:188
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:70
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
5
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
7
msgid "Status"
msgstr "状态"
...
...
@@ -2267,7 +2273,7 @@ msgstr "选择用户"
#: terminal/templates/terminal/command_list.html:60
#: terminal/templates/terminal/session_list.html:61
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:52
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:
48
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:
50
msgid "Search"
msgstr "搜索"
...
...
@@ -2277,7 +2283,7 @@ msgstr "搜索"
#: ops/templates/ops/task_detail.html:56
#: terminal/templates/terminal/session_list.html:70
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:64
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
0
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
2
msgid "ID"
msgstr "ID"
...
...
@@ -2679,7 +2685,7 @@ msgid "Become"
msgstr "Become"
#: ops/models/adhoc.py:166 users/templates/users/user_group_detail.html:59
#: xpack/plugins/cloud/templates/cloud/account_detail.html:6
2
#: xpack/plugins/cloud/templates/cloud/account_detail.html:6
4
#: xpack/plugins/orgs/templates/orgs/org_detail.html:56
msgid "Create by"
msgstr "创建者"
...
...
@@ -2925,8 +2931,8 @@ msgstr "版本"
#: ops/templates/ops/task_list.html:63
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:137
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
3
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
3
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:5
2
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:5
2
msgid "Run"
msgstr "执行"
...
...
@@ -3050,8 +3056,8 @@ msgstr "添加资产"
#: perms/templates/perms/remote_app_permission_remote_app.html:96
#: perms/templates/perms/remote_app_permission_user.html:96
#: perms/templates/perms/remote_app_permission_user.html:124
#: settings/templates/settings/terminal_setting.html:9
5
#: settings/templates/settings/terminal_setting.html:1
17
#: settings/templates/settings/terminal_setting.html:9
8
#: settings/templates/settings/terminal_setting.html:1
20
#: users/templates/users/user_group_detail.html:95
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_asset_list.html:93
#: xpack/plugins/orgs/templates/orgs/org_detail.html:93
...
...
@@ -3111,7 +3117,7 @@ msgstr "创建授权规则"
#: perms/templates/perms/asset_permission_list.html:73
#: perms/templates/perms/remote_app_permission_list.html:18
#: users/templates/users/user_list.html:40 xpack/plugins/cloud/models.py:53
#: xpack/plugins/cloud/templates/cloud/account_detail.html:
58
#: xpack/plugins/cloud/templates/cloud/account_detail.html:
60
#: xpack/plugins/cloud/templates/cloud/account_list.html:14
msgid "Validity"
msgstr "有效"
...
...
@@ -3246,7 +3252,7 @@ msgid "Create succeed"
msgstr "创建成功"
#: settings/api.py:166 settings/api.py:204
#: settings/templates/settings/terminal_setting.html:15
1
#: settings/templates/settings/terminal_setting.html:15
4
msgid "Delete succeed"
msgstr "删除成功"
...
...
@@ -3484,6 +3490,40 @@ msgid ""
"characters"
msgstr "开启后,用户密码修改、重置必须包含特殊字符"
#: settings/forms.py:248
msgid "Create user email subject"
msgstr "创建用户邮件的主题"
#: settings/forms.py:249
msgid ""
"Tips: When creating a user, send the subject of the email (eg:Create account "
"successfully)"
msgstr "提示: 创建用户时,发送设置密码邮件的主题 (例如: 创建用户成功)"
#: settings/forms.py:253
msgid "Create user honorific"
msgstr "创建用户邮件的敬语"
#: settings/forms.py:254
msgid "Tips: When creating a user, send the honorific of the email (eg:Hello)"
msgstr "提示: 创建用户时,发送设置密码邮件的敬语 (例如: 您好)"
#: settings/forms.py:259
msgid "Create user email content"
msgstr "创建用户邮件的内容"
#: settings/forms.py:260
msgid "Tips:When creating a user, send the content of the email"
msgstr "提示: 创建用户时,发送设置密码邮件的内容"
#: settings/forms.py:263
msgid "Signature"
msgstr "署名"
#: settings/forms.py:264
msgid "Tips: Email signature (eg:jumpserver)"
msgstr "提示: 邮件的署名 (例如: jumpserver)"
#: settings/models.py:128 users/templates/users/reset_password.html:68
#: users/templates/users/user_profile.html:20
msgid "Setting"
...
...
@@ -3508,15 +3548,17 @@ msgid "Existing"
msgstr "已存在"
#: settings/templates/settings/basic_setting.html:15
#: settings/templates/settings/email_content_setting.html:15
#: settings/templates/settings/email_setting.html:15
#: settings/templates/settings/ldap_setting.html:15
#: settings/templates/settings/security_setting.html:15
#: settings/templates/settings/terminal_setting.html:16
#: settings/templates/settings/terminal_setting.html:4
6
settings/views.py:19
#: settings/templates/settings/terminal_setting.html:4
9
settings/views.py:19
msgid "Basic setting"
msgstr "基本设置"
#: settings/templates/settings/basic_setting.html:18
#: settings/templates/settings/email_content_setting.html:18
#: settings/templates/settings/email_setting.html:18
#: settings/templates/settings/ldap_setting.html:18
#: settings/templates/settings/security_setting.html:18
...
...
@@ -3525,27 +3567,39 @@ msgid "Email setting"
msgstr "邮件设置"
#: settings/templates/settings/basic_setting.html:21
#: settings/templates/settings/email_content_setting.html:21
#: settings/templates/settings/email_setting.html:21
#: settings/templates/settings/ldap_setting.html:21
#: settings/templates/settings/security_setting.html:21
#: settings/templates/settings/terminal_setting.html:2
4 settings/views.py:71
msgid "
LDAP
setting"
msgstr "
LDAP
设置"
#: settings/templates/settings/terminal_setting.html:2
3 settings/views.py:178
msgid "
Email content
setting"
msgstr "
邮件内容
设置"
#: settings/templates/settings/basic_setting.html:24
#: settings/templates/settings/email_content_setting.html:24
#: settings/templates/settings/email_setting.html:24
#: settings/templates/settings/ldap_setting.html:24
#: settings/templates/settings/security_setting.html:24
#: settings/templates/settings/terminal_setting.html:2
8 settings/views.py:100
msgid "
Terminal
setting"
msgstr "
终端
设置"
#: settings/templates/settings/terminal_setting.html:2
7 settings/views.py:71
msgid "
LDAP
setting"
msgstr "
LDAP
设置"
#: settings/templates/settings/basic_setting.html:27
#: settings/templates/settings/email_content_setting.html:27
#: settings/templates/settings/email_setting.html:27
#: settings/templates/settings/ldap_setting.html:27
#: settings/templates/settings/security_setting.html:27
#: settings/templates/settings/security_setting.html:42
#: settings/templates/settings/terminal_setting.html:31 settings/views.py:152
#: settings/templates/settings/terminal_setting.html:31 settings/views.py:100
msgid "Terminal setting"
msgstr "终端设置"
#: settings/templates/settings/basic_setting.html:30
#: settings/templates/settings/email_content_setting.html:30
#: settings/templates/settings/email_setting.html:30
#: settings/templates/settings/ldap_setting.html:30
#: settings/templates/settings/security_setting.html:30
#: settings/templates/settings/security_setting.html:45
#: settings/templates/settings/terminal_setting.html:34 settings/views.py:152
msgid "Security setting"
msgstr "安全设置"
...
...
@@ -3561,11 +3615,15 @@ msgstr "索引"
msgid "Doc type"
msgstr "文档类型"
#: settings/templates/settings/ldap_setting.html:65
#: settings/templates/settings/email_content_setting.html:45
msgid "Create User setting"
msgstr "创建用户设置"
#: settings/templates/settings/ldap_setting.html:68
msgid "Bulk import"
msgstr "一键导入"
#: settings/templates/settings/ldap_setting.html:11
6
#: settings/templates/settings/ldap_setting.html:11
9
msgid ""
"User is not currently selected, please check the user you want to import"
msgstr "当前无勾选用户,请勾选你想要导入的用户"
...
...
@@ -3627,8 +3685,8 @@ msgstr "端点后缀"
#: settings/templates/settings/replay_storage_create.html:136
#: xpack/plugins/cloud/models.py:186
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:8
1
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
2
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:8
3
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
4
msgid "Region"
msgstr "地域"
...
...
@@ -3652,48 +3710,48 @@ msgstr "提交中"
msgid "Endpoint need contain protocol, ex: http"
msgstr "端点需要包含协议,如 http"
#: settings/templates/settings/security_setting.html:4
6
#: settings/templates/settings/security_setting.html:4
9
msgid "Password check rule"
msgstr "密码校验规则"
#: settings/templates/settings/terminal_setting.html:7
6
terminal/forms.py:27
#: settings/templates/settings/terminal_setting.html:7
9
terminal/forms.py:27
#: terminal/models.py:26
msgid "Command storage"
msgstr "命令存储"
#: settings/templates/settings/terminal_setting.html:
98
terminal/forms.py:32
#: settings/templates/settings/terminal_setting.html:
101
terminal/forms.py:32
#: terminal/models.py:27
msgid "Replay storage"
msgstr "录像存储"
#: settings/templates/settings/terminal_setting.html:15
4
#: settings/templates/settings/terminal_setting.html:15
7
msgid "Delete failed"
msgstr "删除失败"
#: settings/templates/settings/terminal_setting.html:1
59
#: settings/templates/settings/terminal_setting.html:1
62
msgid "Are you sure about deleting it?"
msgstr "您确定删除吗?"
#: settings/utils.py:
69
#: settings/utils.py:
71
msgid "User does not exist"
msgstr "用户不存在"
#: settings/utils.py:7
2
#: settings/utils.py:7
4
msgid "The user source is not LDAP"
msgstr "用户来源不是LDAP"
#: settings/utils.py:1
46
#: settings/utils.py:1
55
msgid "Search no entry matched in ou {}"
msgstr "在ou:{}中没有匹配条目"
#: settings/views.py:18 settings/views.py:44 settings/views.py:70
#: settings/views.py:99 settings/views.py:126 settings/views.py:138
#: settings/views.py:151 templates/_nav.html:118
#: settings/views.py:151
settings/views.py:177
templates/_nav.html:118
msgid "Settings"
msgstr "系统设置"
#: settings/views.py:29 settings/views.py:55 settings/views.py:81
#: settings/views.py:112 settings/views.py:162
#: settings/views.py:112 settings/views.py:162
settings/views.py:188
msgid "Update setting successfully"
msgstr "更新设置成功"
...
...
@@ -4464,7 +4522,7 @@ msgstr "安全令牌验证"
#: users/templates/users/_base_otp.html:44 users/templates/users/_user.html:13
#: users/templates/users/user_profile_update.html:51
#: xpack/plugins/cloud/models.py:120
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:5
7
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:5
9
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:13
msgid "Account"
msgstr "账户"
...
...
@@ -4572,7 +4630,7 @@ msgid "Always young, always with tears in my eyes. Stay foolish Stay hungry"
msgstr "永远年轻,永远热泪盈眶 stay foolish stay hungry"
#: users/templates/users/reset_password.html:46
#: users/templates/users/user_detail.html:373 users/utils.py:
77
#: users/templates/users/user_detail.html:373 users/utils.py:
98
msgid "Reset password"
msgstr "重置密码"
...
...
@@ -4893,55 +4951,60 @@ msgid ""
msgstr "新的公钥已设置成功,请下载对应的私钥"
#: users/utils.py:38
msgid "Create account successfully"
msgstr "创建账户成功"
#: users/utils.py:40
#, python-format
msgid ""
"\n"
" Hello %(name)s:\n"
" </br>\n"
" Your account has been created successfully\n"
" </br>\n"
" Username: %(username)s\n"
" </br>\n"
" <a href=\"%(rest_password_url)s?token=%(rest_password_token)s\">click "
"here to set your password</a>\n"
" </br>\n"
" This link is valid for 1 hour. After it expires, <a href="
" <link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/"
"bootstrap/3.2.0/css/bootstrap.min.css\">\n"
" <p style=\"text-indent:2em;\">\n"
" <span>\n"
" Username: %(username)s.\n"
" </span>\n"
" <span>\n"
" <a href=\"%(rest_password_url)s?token=%(rest_password_token)s"
"\">click here to set your password</a>\n"
" </span> \n"
" <span>\n"
" This link is valid for 1 hour. After it expires, <a href="
"\"%(forget_password_url)s?email=%(email)s\">request new one</a>\n"
"\n"
" </br>\n"
" ---\n"
"\n"
" </br>\n"
" <a href=\"%(login_url)s\">Login direct</a>\n"
"\n"
" </br>\n"
" "
" </span> \n"
" <span>\n"
" <a href=\"%(login_url)s\">Login direct</a>\n"
" </span>\n"
" </p>\n"
" "
msgstr ""
"\n"
" 你好 %(name)s:\n"
" </br>\n"
" 恭喜您,您的账号已经创建成功 </br>\n"
" 用户名: %(username)s\n"
" </br>\n"
" <a href=\"%(rest_password_url)s?token=%(rest_password_token)s\">请点击这"
"里设置密码</a> </br>\n"
" 这个链接有效期1小时, 超过时间您可以 <a href=\"%(forget_password_url)s?"
"email=%(email)s\">重新申请</a>\n"
"\n"
" </br>\n"
" ---\n"
"\n"
" </br>\n"
" <a href=\"%(login_url)s\">Login direct</a>\n"
"\n"
" </br>\n"
" <link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/"
"bootstrap/3.2.0/css/bootstrap.min.css\">\n"
" <p style=\"text-indent:2em;\">\n"
" <span>\n"
" 用户名: %(username)s.\n"
" </span>\n"
" <span>\n"
" <a href=\"%(rest_password_url)s?token=%(rest_password_token)s\">"
"请点击这里设置密码</a>\n"
" </span> \n"
" <span>\n"
" 这个链接有效期1小时, 超过时间您可以 <a href="
"\"%(forget_password_url)s?email=%(email)s\">重新申请</a>\n"
" </span> \n"
" <span>\n"
" <a href=\"%(login_url)s\">---登录页面</a>\n"
" </span>\n"
" </p>\n"
" "
#: users/utils.py:79
#: users/utils.py:73
msgid "Create account successfully"
msgstr "创建账户成功"
#: users/utils.py:77
#, python-format
msgid "Hello %(name)s"
msgstr "您好 %(name)s"
#: users/utils.py:100
#, python-format
msgid ""
"\n"
...
...
@@ -4985,11 +5048,11 @@ msgstr ""
" </br>\n"
" "
#: users/utils.py:1
10
#: users/utils.py:1
31
msgid "Security notice"
msgstr "安全通知"
#: users/utils.py:1
12
#: users/utils.py:1
33
#, python-format
msgid ""
"\n"
...
...
@@ -5038,11 +5101,11 @@ msgstr ""
" </br>\n"
" "
#: users/utils.py:1
48
#: users/utils.py:1
69
msgid "SSH Key Reset"
msgstr "重置ssh密钥"
#: users/utils.py:1
50
#: users/utils.py:1
71
#, python-format
msgid ""
"\n"
...
...
@@ -5067,15 +5130,15 @@ msgstr ""
" </br>\n"
" "
#: users/utils.py:
183
#: users/utils.py:
204
msgid "User not exist"
msgstr "用户不存在"
#: users/utils.py:
185
#: users/utils.py:
206
msgid "Disabled or expired"
msgstr "禁用或失效"
#: users/utils.py:
198
#: users/utils.py:
219
msgid "Password or SSH public key invalid"
msgstr "密码或密钥不合法"
...
...
@@ -5341,7 +5404,7 @@ msgid "Run plan manually"
msgstr "手动执行计划"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:179
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:10
2
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:10
1
msgid "Execute failed"
msgstr "执行失败"
...
...
@@ -5427,7 +5490,7 @@ msgid "Unavailable"
msgstr "无效"
#: xpack/plugins/cloud/models.py:50
#: xpack/plugins/cloud/templates/cloud/account_detail.html:5
4
#: xpack/plugins/cloud/templates/cloud/account_detail.html:5
6
#: xpack/plugins/cloud/templates/cloud/account_list.html:13
msgid "Provider"
msgstr "云服务商"
...
...
@@ -5453,7 +5516,7 @@ msgid "Instances"
msgstr "实例"
#: xpack/plugins/cloud/models.py:126
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:7
3
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:7
5
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:17
msgid "Date last sync"
msgstr "最后同步日期"
...
...
@@ -5472,7 +5535,7 @@ msgstr ""
#: xpack/plugins/cloud/models.py:173 xpack/plugins/cloud/models.py:189
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:71
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
6
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
8
msgid "Date sync"
msgstr "同步日期"
...
...
@@ -5489,8 +5552,8 @@ msgid "Sync instance task history"
msgstr "同步实例任务历史"
#: xpack/plugins/cloud/models.py:185
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:
89
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
1
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:
91
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:6
3
msgid "Instance"
msgstr "实例"
...
...
@@ -5510,7 +5573,7 @@ msgstr "AWS (国际)"
msgid "Qcloud"
msgstr "腾讯云"
#: xpack/plugins/cloud/templates/cloud/account_detail.html:2
0
#: xpack/plugins/cloud/templates/cloud/account_detail.html:2
2
#: xpack/plugins/cloud/views.py:72
msgid "Account detail"
msgstr "账户详情"
...
...
@@ -5528,23 +5591,23 @@ msgstr "加载中..."
msgid "Load failed"
msgstr "加载失败"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:2
0
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:2
2
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:25
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:2
1
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:2
3
#: xpack/plugins/cloud/views.py:122
msgid "Sync task detail"
msgstr "同步任务详情"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:2
3
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:2
5
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:28
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:2
4
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:2
6
#: xpack/plugins/cloud/views.py:137
msgid "Sync task history"
msgstr "同步历史列表"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:2
6
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:2
8
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:31
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:2
7
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:2
9
#: xpack/plugins/cloud/views.py:188
msgid "Sync instance list"
msgstr "同步实例列表"
...
...
@@ -5577,7 +5640,7 @@ msgstr "执行次数"
msgid "Instance count"
msgstr "实例个数"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:9
3
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:9
2
msgid "Sync success"
msgstr "同步成功"
...
...
@@ -5661,7 +5724,6 @@ msgid "This will restore default Settings of the interface !!!"
msgstr "您确定要恢复默认初始化吗?"
#: xpack/plugins/interface/templates/interface/interface.html:107
#: xpack/plugins/interface/views.py:53
msgid "Restore default successfully."
msgstr "恢复默认成功!"
...
...
@@ -5674,9 +5736,13 @@ msgid "Interface"
msgstr "界面"
#: xpack/plugins/interface/views.py:49
msgid "It is already in the default setting state
!
"
msgid "It is already in the default setting state
!
"
msgstr "当前已经是初始化状态!"
#: xpack/plugins/interface/views.py:53
msgid "Restore default successfully!"
msgstr "恢复默认成功!"
#: xpack/plugins/license/meta.py:11 xpack/plugins/license/models.py:94
#: xpack/plugins/license/templates/license/license_detail.html:50
#: xpack/plugins/license/templates/license/license_detail.html:55
...
...
@@ -5817,6 +5883,45 @@ msgstr "更新组织"
#~ msgid "Update user groups"
#~ msgstr "更新用户组"
# msgid "Update user"
# msgstr "更新用户"
#~ msgid ""
#~ "\n"
#~ " <link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/"
#~ "bootstrap/3.2.0/css/bootstrap.min.css\">\n"
#~ " <p style=\"text-indent:2em;\">\n"
#~ " <span>\n"
#~ " <a href=\"%(rest_password_url)s?token="
#~ "%(rest_password_token)s\">click here to set your password</a>\n"
#~ " </span> \n"
#~ " <span>\n"
#~ " This link is valid for 1 hour. After it expires, <a href="
#~ "\"%(forget_password_url)s?email=%(email)s\">request new one</a>\n"
#~ " </span> \n"
#~ " <span>\n"
#~ " <a href=\"%(login_url)s\">Login direct</a>\n"
#~ " </span>\n"
#~ " </p>\n"
#~ " "
#~ msgstr ""
#~ "\n"
#~ " <link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/"
#~ "bootstrap/3.2.0/css/bootstrap.min.css\">\n"
#~ " <p style=\"text-indent:2em;\">\n"
#~ " <span>\n"
#~ " <a href=\"%(rest_password_url)s?token="
#~ "%(rest_password_token)s\">请点击这里设置密码</a>\n"
#~ " </span> \n"
#~ " <span>\n"
#~ " 这个链接有效期1小时, 超过时间您可以, <a href="
#~ "\"%(forget_password_url)s?email=%(email)s\">重新申请</a>\n"
#~ " </span> \n"
#~ " <span>\n"
#~ " <a href=\"%(login_url)s\">Login direct</a>\n"
#~ " </span>\n"
#~ " </p>\n"
#~ " "
#~ msgid "Template"
#~ msgstr "模板"
...
...
@@ -5851,9 +5956,6 @@ msgstr "更新组织"
#~ msgid "Select host"
#~ msgstr "选择资产"
#~ msgid "Restore default successfully!"
#~ msgstr "恢复默认成功!"
#~ msgid "Beijing Duizhan Tech, Inc."
#~ msgstr "北京堆栈科技有限公司"
...
...
apps/perms/api/user_permission.py
View file @
b237cbb2
...
...
@@ -512,6 +512,7 @@ class UserGrantedRemoteAppsAsTreeApi(ListAPIView):
class
ValidateUserRemoteAppPermissionApi
(
APIView
):
permission_classes
=
(
IsOrgAdminOrAppUser
,)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
user_id
=
request
.
query_params
.
get
(
'user_id'
,
''
)
...
...
apps/settings/api.py
View file @
b237cbb2
...
...
@@ -79,7 +79,7 @@ class LDAPTestingAPI(APIView):
util
=
self
.
get_ldap_util
(
serializer
)
try
:
users
=
util
.
get_
search_user_items
()
users
=
util
.
search_user_items
()
except
Exception
as
e
:
return
Response
({
"error"
:
str
(
e
)},
status
=
401
)
...
...
@@ -95,7 +95,7 @@ class LDAPUserListApi(APIView):
def
get
(
self
,
request
):
util
=
LDAPUtil
()
try
:
users
=
util
.
get_
search_user_items
()
users
=
util
.
search_user_items
()
except
Exception
as
e
:
users
=
[]
logger
.
error
(
e
,
exc_info
=
True
)
...
...
@@ -108,11 +108,11 @@ class LDAPUserSyncAPI(APIView):
permission_classes
=
(
IsOrgAdmin
,)
def
post
(
self
,
request
):
user
_names
=
request
.
data
.
get
(
'user_names'
,
''
)
user
name_list
=
request
.
data
.
get
(
'username_list'
,
[]
)
util
=
LDAPUtil
()
try
:
result
=
util
.
sync_users
(
username_
set
=
user_names
)
result
=
util
.
sync_users
(
username_
list
)
except
Exception
as
e
:
logger
.
error
(
e
,
exc_info
=
True
)
return
Response
({
'error'
:
str
(
e
)},
status
=
401
)
...
...
apps/settings/forms.py
View file @
b237cbb2
...
...
@@ -242,3 +242,26 @@ class SecuritySettingForm(BaseForm):
'and resets must contain special characters'
)
)
class
EmailContentSettingForm
(
BaseForm
):
EMAIL_CUSTOM_USER_CREATED_SUBJECT
=
forms
.
CharField
(
max_length
=
1024
,
required
=
False
,
label
=
_
(
"Create user email subject"
),
help_text
=
_
(
"Tips: When creating a user, send the subject of the email"
" (eg:Create account successfully)"
)
)
EMAIL_CUSTOM_USER_CREATED_HONORIFIC
=
forms
.
CharField
(
max_length
=
1024
,
required
=
False
,
label
=
_
(
"Create user honorific"
),
help_text
=
_
(
"Tips: When creating a user, send the honorific of the "
"email (eg:Hello)"
)
)
EMAIL_CUSTOM_USER_CREATED_BODY
=
forms
.
CharField
(
max_length
=
4096
,
required
=
False
,
widget
=
forms
.
Textarea
(),
label
=
_
(
'Create user email content'
),
help_text
=
_
(
'Tips:When creating a user, send the content of the email'
)
)
EMAIL_CUSTOM_USER_CREATED_SIGNATURE
=
forms
.
CharField
(
max_length
=
512
,
required
=
False
,
label
=
_
(
"Signature"
),
help_text
=
_
(
"Tips: Email signature (eg:jumpserver)"
)
)
apps/settings/templates/settings/_ldap_list_users_modal.html
View file @
b237cbb2
...
...
@@ -58,6 +58,9 @@ function initLdapUsersTable() {
ele
:
$
(
'#ldap_list_users_table'
),
ajax_url
:
'{% url "api-settings:ldap-user-list" %}'
,
columnDefs
:
[
{
targets
:
0
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
$
(
td
).
html
(
"<input type='checkbox' class='text-center ipt_check' id='ID_USERNAME'>"
.
replace
(
"ID_USERNAME"
,
cellData
))
}},
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
if
(
cellData
){
$
(
td
).
html
(
'<i class="fa fa-check text-navy"></i>'
)
...
...
apps/settings/templates/settings/basic_setting.html
View file @
b237cbb2
...
...
@@ -17,6 +17,9 @@
<li>
<a
href=
"{% url 'settings:email-setting' %}"
class=
"text-center"
><i
class=
"fa fa-envelope"
></i>
{% trans 'Email setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:email-content-setting' %}"
class=
"text-center"
><i
class=
"fa fa-file-text"
></i>
{% trans 'Email content setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:ldap-setting' %}"
class=
"text-center"
><i
class=
"fa fa-archive"
></i>
{% trans 'LDAP setting' %}
</a>
</li>
...
...
apps/settings/templates/settings/email_content_setting.html
0 → 100644
View file @
b237cbb2
{% extends 'base.html' %}
{% load static %}
{% load bootstrap3 %}
{% load i18n %}
{% load common_tags %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li>
<a
href=
"{% url 'settings:basic-setting' %}"
class=
"text-center"
><i
class=
"fa fa-cubes"
></i>
{% trans 'Basic setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:email-setting' %}"
class=
"text-center"
><i
class=
"fa fa-envelope"
></i>
{% trans 'Email setting' %}
</a>
</li>
<li
class=
"active"
>
<a
href=
"{% url 'settings:email-content-setting' %}"
class=
"text-center"
><i
class=
"fa fa-file-text"
></i>
{% trans 'Email content setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:ldap-setting' %}"
class=
"text-center"
><i
class=
"fa fa-archive"
></i>
{% trans 'LDAP setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:terminal-setting' %}"
class=
"text-center"
><i
class=
"fa fa-hdd-o"
></i>
{% trans 'Terminal setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:security-setting' %}"
class=
"text-center"
><i
class=
"fa fa-lock"
></i>
{% trans 'Security setting' %}
</a>
</li>
</ul>
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-12"
style=
"padding-left:0"
>
<div
class=
"ibox-content"
style=
"border-width: 0;padding-top: 40px;"
>
<form
action=
""
method=
"post"
class=
"form-horizontal"
>
{% if form.non_field_errors %}
<div
class=
"alert alert-danger"
>
{{ form.non_field_errors }}
</div>
{% endif %}
{% csrf_token %}
<h3>
{% trans "Create User setting" %}
</h3>
{% bootstrap_field form.EMAIL_CUSTOM_USER_CREATED_SUBJECT layout="horizontal" %}
{% bootstrap_field form.EMAIL_CUSTOM_USER_CREATED_HONORIFIC layout="horizontal" %}
{% bootstrap_field form.EMAIL_CUSTOM_USER_CREATED_BODY layout="horizontal" %}
{% bootstrap_field form.EMAIL_CUSTOM_USER_CREATED_SIGNATURE layout="horizontal" %}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-default"
type=
"reset"
>
{% trans 'Reset' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
</script>
{% endblock %}
apps/settings/templates/settings/email_setting.html
View file @
b237cbb2
...
...
@@ -17,6 +17,9 @@
<li
class=
"active"
>
<a
href=
"{% url 'settings:email-setting' %}"
class=
"text-center"
><i
class=
"fa fa-envelope"
></i>
{% trans 'Email setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:email-content-setting' %}"
class=
"text-center"
><i
class=
"fa fa-file-text"
></i>
{% trans 'Email content setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:ldap-setting' %}"
class=
"text-center"
><i
class=
"fa fa-archive"
></i>
{% trans 'LDAP setting' %}
</a>
</li>
...
...
apps/settings/templates/settings/ldap_setting.html
View file @
b237cbb2
...
...
@@ -17,6 +17,9 @@
<li>
<a
href=
"{% url 'settings:email-setting' %}"
class=
"text-center"
><i
class=
"fa fa-envelope"
></i>
{% trans 'Email setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:email-content-setting' %}"
class=
"text-center"
><i
class=
"fa fa-file-text"
></i>
{% trans 'Email content setting' %}
</a>
</li>
<li
class=
"active"
>
<a
href=
"{% url 'settings:ldap-setting' %}"
class=
"text-center"
><i
class=
"fa fa-archive"
></i>
{% trans 'LDAP setting' %}
</a>
</li>
...
...
@@ -107,13 +110,13 @@ $(document).ready(function () {
});
})
.
on
(
"click"
,
"#btn_ldap_modal_confirm"
,
function
()
{
var
user
_names
=
[];
var
user
name_list
=
[];
$
(
"tbody input[type='checkbox']:checked"
).
each
(
function
()
{
user
_names
.
push
(
$
(
this
).
attr
(
'id'
));
user
name_list
.
push
(
$
(
this
).
attr
(
'id'
));
});
if
(
user
_names
.
length
===
0
){
var
msg
=
"{% trans 'User is not currently selected, please check the user you want to import'%}"
if
(
user
name_list
.
length
===
0
){
var
msg
=
"{% trans 'User is not currently selected, please check the user you want to import'%}"
;
toastr
.
error
(
msg
);
return
}
...
...
@@ -129,7 +132,7 @@ $(document).ready(function () {
}
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
({
'user
_names'
:
user_names
}),
body
:
JSON
.
stringify
({
'user
name_list'
:
username_list
}),
method
:
"POST"
,
flash_message
:
false
,
success
:
success
,
...
...
apps/settings/templates/settings/security_setting.html
View file @
b237cbb2
...
...
@@ -16,6 +16,9 @@
</li>
<li>
<a
href=
"{% url 'settings:email-setting' %}"
class=
"text-center"
><i
class=
"fa fa-envelope"
></i>
{% trans 'Email setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:email-content-setting' %}"
class=
"text-center"
><i
class=
"fa fa-file-text"
></i>
{% trans 'Email content setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:ldap-setting' %}"
class=
"text-center"
><i
class=
"fa fa-archive"
></i>
{% trans 'LDAP setting' %}
</a>
...
...
apps/settings/templates/settings/terminal_setting.html
View file @
b237cbb2
...
...
@@ -18,6 +18,9 @@
<li>
<a
href=
"{% url 'settings:email-setting' %}"
class=
"text-center"
><i
class=
"fa fa-envelope"
></i>
{% trans 'Email setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:email-content-setting' %}"
class=
"text-center"
><i
class=
"fa fa-file-text"
></i>
{% trans 'Email content setting' %}
</a>
</li>
<li>
<a
href=
"{% url 'settings:ldap-setting' %}"
class=
"text-center"
><i
...
...
apps/settings/urls/view_urls.py
View file @
b237cbb2
...
...
@@ -9,6 +9,7 @@ app_name = 'common'
urlpatterns
=
[
url
(
r'^$'
,
views
.
BasicSettingView
.
as_view
(),
name
=
'basic-setting'
),
url
(
r'^email/$'
,
views
.
EmailSettingView
.
as_view
(),
name
=
'email-setting'
),
url
(
r'^email-content/$'
,
views
.
EmailContentSettingView
.
as_view
(),
name
=
'email-content-setting'
),
url
(
r'^ldap/$'
,
views
.
LDAPSettingView
.
as_view
(),
name
=
'ldap-setting'
),
url
(
r'^terminal/$'
,
views
.
TerminalSettingView
.
as_view
(),
name
=
'terminal-setting'
),
url
(
r'^terminal/replay-storage/create$'
,
views
.
ReplayStorageCreateView
.
as_view
(),
name
=
'replay-storage-create'
),
...
...
apps/settings/utils.py
View file @
b237cbb2
...
...
@@ -5,7 +5,9 @@ from ldap3 import Server, Connection
from
django.utils.translation
import
ugettext_lazy
as
_
from
users.models
import
User
from
users.utils
import
construct_user_email
from
common.utils
import
get_logger
from
.models
import
settings
...
...
@@ -17,11 +19,11 @@ class LDAPOUGroupException(Exception):
class
LDAPUtil
:
_conn
=
None
def
__init__
(
self
,
use_settings_config
=
True
,
server_uri
=
None
,
bind_dn
=
None
,
password
=
None
,
use_ssl
=
None
,
search_ougroup
=
None
,
search_filter
=
None
,
attr_map
=
None
,
auth_ldap
=
None
):
# config
if
use_settings_config
:
self
.
_load_config_from_settings
()
...
...
@@ -45,6 +47,15 @@ class LDAPUtil:
self
.
attr_map
=
settings
.
AUTH_LDAP_USER_ATTR_MAP
self
.
auth_ldap
=
settings
.
AUTH_LDAP
@property
def
connection
(
self
):
if
self
.
_conn
is
None
:
server
=
Server
(
self
.
server_uri
,
use_ssl
=
self
.
use_ssl
)
conn
=
Connection
(
server
,
self
.
bind_dn
,
self
.
password
)
conn
.
bind
()
self
.
_conn
=
conn
return
self
.
_conn
@staticmethod
def
get_user_by_username
(
username
):
try
:
...
...
@@ -55,36 +66,64 @@ class LDAPUtil:
else
:
return
user
def
_ldap_entry_to_user_item
(
self
,
entry
):
user_item
=
{}
for
attr
,
mapping
in
self
.
attr_map
.
items
():
if
not
hasattr
(
entry
,
mapping
):
continue
user_item
[
attr
]
=
getattr
(
entry
,
mapping
)
.
value
or
''
return
user_item
def
search_user_items
(
self
):
user_items
=
[]
for
search_ou
in
str
(
self
.
search_ougroup
)
.
split
(
"|"
):
ok
=
self
.
connection
.
search
(
search_ou
,
self
.
search_filter
%
({
"user"
:
"*"
}),
attributes
=
list
(
self
.
attr_map
.
values
())
)
if
not
ok
:
error
=
_
(
"Search no entry matched in ou {}"
.
format
(
search_ou
))
raise
LDAPOUGroupException
(
error
)
for
entry
in
self
.
connection
.
entries
:
user_item
=
self
.
_ldap_entry_to_user_item
(
entry
)
user
=
self
.
get_user_by_username
(
user_item
[
'username'
])
user_item
[
'existing'
]
=
bool
(
user
)
user_items
.
append
(
user_item
)
return
user_items
def
search_filter_user_items
(
self
,
username_list
):
user_items
=
self
.
search_user_items
()
if
username_list
:
user_items
=
[
u
for
u
in
user_items
if
u
[
'username'
]
in
username_list
]
return
user_items
@staticmethod
def
_updat
e_user
(
user
,
user_item
):
def
sav
e_user
(
user
,
user_item
):
for
field
,
value
in
user_item
.
items
():
if
not
hasattr
(
user
,
field
):
continue
if
isinstance
(
getattr
(
user
,
field
),
bool
):
value
=
value
.
lower
()
in
[
'true'
,
1
]
setattr
(
user
,
field
,
value
)
user
.
save
()
def
update_user
(
self
,
user_item
):
user
=
self
.
get_user_by_username
(
user_item
[
'username'
])
if
not
user
:
msg
=
_
(
'User does not exist'
)
return
False
,
msg
if
user
.
source
!=
User
.
SOURCE_LDAP
:
msg
=
_
(
'The user source is not LDAP'
)
return
False
,
msg
try
:
self
.
_updat
e_user
(
user
,
user_item
)
self
.
sav
e_user
(
user
,
user_item
)
except
Exception
as
e
:
logger
.
error
(
e
,
exc_info
=
True
)
return
False
,
str
(
e
)
else
:
return
True
,
None
@staticmethod
def
create_user
(
user_item
):
user_item
[
'source'
]
=
User
.
SOURCE_LDAP
def
create_user
(
self
,
user_item
):
user
=
User
(
source
=
User
.
SOURCE_LDAP
)
try
:
User
.
objects
.
create
(
**
user_item
)
self
.
save_user
(
user
,
user_item
)
except
Exception
as
e
:
logger
.
error
(
e
,
exc_info
=
True
)
return
False
,
str
(
e
)
...
...
@@ -92,26 +131,21 @@ class LDAPUtil:
return
True
,
None
@staticmethod
def
get_or_construct_email
(
user_item
):
if
not
user_item
.
get
(
'email'
,
None
):
if
'@'
in
user_item
[
'username'
]:
email
=
user_item
[
'username'
]
else
:
email
=
'{}@{}'
.
format
(
user_item
[
'username'
],
settings
.
EMAIL_SUFFIX
)
else
:
email
=
user_item
[
'email'
]
def
construct_user_email
(
user_item
):
username
=
user_item
[
'username'
]
email
=
user_item
.
get
(
'email'
,
''
)
email
=
construct_user_email
(
username
,
email
)
return
email
def
create_or_update_users
(
self
,
user_items
,
force_update
=
True
):
succeed
=
failed
=
0
for
user_item
in
user_items
:
user_item
[
'email'
]
=
self
.
get_or_construct_email
(
user_item
)
exist
=
user_item
.
pop
(
'existing'
,
None
)
if
exist
:
ok
,
error
=
self
.
update_user
(
user_item
)
else
:
exist
=
user_item
.
pop
(
'existing'
,
False
)
user_item
[
'email'
]
=
self
.
construct_user_email
(
user_item
)
if
not
exist
:
ok
,
error
=
self
.
create_user
(
user_item
)
else
:
ok
,
error
=
self
.
update_user
(
user_item
)
if
not
ok
:
failed
+=
1
else
:
...
...
@@ -119,44 +153,7 @@ class LDAPUtil:
result
=
{
'total'
:
len
(
user_items
),
'succeed'
:
succeed
,
'failed'
:
failed
}
return
result
def
_ldap_entry_to_user_item
(
self
,
entry
):
user_item
=
{}
for
attr
,
mapping
in
self
.
attr_map
.
items
():
if
not
hasattr
(
entry
,
mapping
):
continue
user_item
[
attr
]
=
getattr
(
entry
,
mapping
)
.
value
or
''
return
user_item
def
get_connection
(
self
):
server
=
Server
(
self
.
server_uri
,
use_ssl
=
self
.
use_ssl
)
conn
=
Connection
(
server
,
self
.
bind_dn
,
self
.
password
)
conn
.
bind
()
return
conn
def
get_search_user_items
(
self
):
conn
=
self
.
get_connection
()
user_items
=
[]
search_ougroup
=
str
(
self
.
search_ougroup
)
.
split
(
"|"
)
for
search_ou
in
search_ougroup
:
ok
=
conn
.
search
(
search_ou
,
self
.
search_filter
%
({
"user"
:
"*"
}),
attributes
=
list
(
self
.
attr_map
.
values
())
)
if
not
ok
:
error
=
_
(
"Search no entry matched in ou {}"
.
format
(
search_ou
))
raise
LDAPOUGroupException
(
error
)
for
entry
in
conn
.
entries
:
user_item
=
self
.
_ldap_entry_to_user_item
(
entry
)
user
=
self
.
get_user_by_username
(
user_item
[
'username'
])
user_item
[
'existing'
]
=
bool
(
user
)
user_items
.
append
(
user_item
)
return
user_items
def
sync_users
(
self
,
username_set
):
user_items
=
self
.
get_search_user_items
()
if
username_set
:
user_items
=
[
u
for
u
in
user_items
if
u
[
'username'
]
in
username_set
]
def
sync_users
(
self
,
username_list
):
user_items
=
self
.
search_filter_user_items
(
username_list
)
result
=
self
.
create_or_update_users
(
user_items
)
return
result
apps/settings/views.py
View file @
b237cbb2
...
...
@@ -6,7 +6,7 @@ from django.utils.translation import ugettext as _
from
common.permissions
import
SuperUserRequiredMixin
from
common
import
utils
from
.forms
import
EmailSettingForm
,
LDAPSettingForm
,
BasicSettingForm
,
\
TerminalSettingForm
,
SecuritySettingForm
TerminalSettingForm
,
SecuritySettingForm
,
EmailContentSettingForm
class
BasicSettingView
(
SuperUserRequiredMixin
,
TemplateView
):
...
...
@@ -166,3 +166,29 @@ class SecuritySettingView(SuperUserRequiredMixin, TemplateView):
context
=
self
.
get_context_data
()
context
.
update
({
"form"
:
form
})
return
render
(
request
,
self
.
template_name
,
context
)
class
EmailContentSettingView
(
SuperUserRequiredMixin
,
TemplateView
):
template_name
=
"settings/email_content_setting.html"
form_class
=
EmailContentSettingForm
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
_
(
'Settings'
),
'action'
:
_
(
'Email content setting'
),
'form'
:
self
.
form_class
(),
}
kwargs
.
update
(
context
)
return
super
()
.
get_context_data
(
**
kwargs
)
def
post
(
self
,
request
):
form
=
self
.
form_class
(
request
.
POST
)
if
form
.
is_valid
():
form
.
save
()
msg
=
_
(
"Update setting successfully"
)
messages
.
success
(
request
,
msg
)
return
redirect
(
'settings:email-content-setting'
)
else
:
context
=
self
.
get_context_data
()
context
.
update
({
"form"
:
form
})
return
render
(
request
,
self
.
template_name
,
context
)
apps/users/utils.py
View file @
b237cbb2
...
...
@@ -34,29 +34,24 @@ class AdminUserRequiredMixin(UserPassesTestMixin):
return
True
def
send_user_created_mail
(
user
):
subject
=
_
(
'Create account successfully'
)
recipient_list
=
[
user
.
email
]
message
=
_
(
"""
Hello
%(name)
s:
</br>
Your account has been created successfully
</br>
Username:
%(username)
s
</br>
<a href="
%(rest_password_url)
s?token=
%(rest_password_token)
s">click here to set your password</a>
</br>
This link is valid for 1 hour. After it expires, <a href="
%(forget_password_url)
s?email=
%(email)
s">request new one</a>
</br>
---
</br>
<a href="
%(login_url)
s">Login direct</a>
</br>
"""
)
%
{
'name'
:
user
.
name
,
def
construct_user_created_email_body
(
user
):
default_body
=
_
(
"""
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<p style="text-indent:2em;">
<span>
Username:
%(username)
s.
</span>
<span>
<a href="
%(rest_password_url)
s?token=
%(rest_password_token)
s">click here to set your password</a>
</span>
<span>
This link is valid for 1 hour. After it expires, <a href="
%(forget_password_url)
s?email=
%(email)
s">request new one</a>
</span>
<span>
<a href="
%(login_url)
s">Login direct</a>
</span>
</p>
"""
)
%
{
'username'
:
user
.
username
,
'rest_password_url'
:
reverse
(
'users:reset-password'
,
external
=
True
),
'rest_password_token'
:
user
.
generate_reset_token
(),
...
...
@@ -64,6 +59,32 @@ def send_user_created_mail(user):
'email'
:
user
.
email
,
'login_url'
:
reverse
(
'authentication:login'
,
external
=
True
),
}
if
settings
.
EMAIL_CUSTOM_USER_CREATED_BODY
:
custom_body
=
'<p style="text-indent:2em">'
+
settings
.
EMAIL_CUSTOM_USER_CREATED_BODY
+
'</p>'
else
:
custom_body
=
''
body
=
custom_body
+
default_body
return
body
def
send_user_created_mail
(
user
):
recipient_list
=
[
user
.
email
]
subject
=
_
(
'Create account successfully'
)
if
settings
.
EMAIL_CUSTOM_USER_CREATED_SUBJECT
:
subject
=
settings
.
EMAIL_CUSTOM_USER_CREATED_SUBJECT
honorific
=
'<p>'
+
_
(
'Hello
%(name)
s'
)
%
{
'name'
:
user
.
name
}
+
':</p>'
if
settings
.
EMAIL_CUSTOM_USER_CREATED_HONORIFIC
:
honorific
=
'<p>'
+
settings
.
EMAIL_CUSTOM_USER_CREATED_HONORIFIC
+
':</p>'
body
=
construct_user_created_email_body
(
user
)
signature
=
'<p style="float:right">jumpserver</p>'
if
settings
.
EMAIL_CUSTOM_USER_CREATED_SIGNATURE
:
signature
=
'<p style="float:right">'
+
settings
.
EMAIL_CUSTOM_USER_CREATED_SIGNATURE
+
'</p>'
message
=
honorific
+
body
+
signature
if
settings
.
DEBUG
:
try
:
print
(
message
)
...
...
@@ -313,3 +334,13 @@ def is_need_unblock(key_block):
if
not
cache
.
get
(
key_block
):
return
False
return
True
def
construct_user_email
(
username
,
email
):
if
'@'
not
in
email
:
if
'@'
in
username
:
email
=
username
else
:
email
=
'{}@{}'
.
format
(
username
,
settings
.
EMAIL_SUFFIX
)
return
email
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment