Merge pull request #3633 from jumpserver/dev

Dev
pull/3671/head
BaiJiangJie 2020-01-14 16:56:04 +08:00 committed by GitHub
commit 17956bf0db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 176 additions and 69 deletions

View File

@ -16,6 +16,8 @@
from django.db import transaction
from django.db.models import Count
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
from rest_framework import status
from rest_framework.response import Response
from orgs.mixins.api import OrgBulkModelViewSet
from orgs.mixins import generics
@ -50,6 +52,14 @@ class AdminUserViewSet(OrgBulkModelViewSet):
queryset = queryset.annotate(_assets_amount=Count('assets'))
return queryset
def destroy(self, request, *args, **kwargs):
instance = self.get_object()
has_related_asset = instance.assets.exists()
if has_related_asset:
data = {'msg': _('Deleted failed, There are related assets')}
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
return super().destroy(request, *args, **kwargs)
class AdminUserAuthApi(generics.UpdateAPIView):
model = AdminUser

View File

@ -137,7 +137,7 @@ class SystemUser(AssetUser):
@property
def is_need_cmd_filter(self):
return self.protocol not in [self.PROTOCOL_RDP, self.PROTOCOL_MYSQL]
return self.protocol not in [self.PROTOCOL_RDP, self.PROTOCOL_VNC]
@property
def is_need_test_asset_connective(self):

View File

@ -88,6 +88,7 @@ var auto_generate_key = '#'+'{{ form.auto_generate_key.id_for_label }}';
var password_id = '#' + '{{ form.password.id_for_label }}';
var private_key_id = '#' + '{{ form.private_key.id_for_label }}';
var auto_push_id = '#' + '{{ form.auto_push.id_for_label }}';
var command_filter_block_id = '#command-filter-block';
var sudo_id = '#' + '{{ form.sudo.id_for_label }}';
var shell_id = '#' + '{{ form.shell.id_for_label }}';
@ -101,17 +102,27 @@ function autoLoginModeProtocol() {
$(private_key_id).closest('.form-group').addClass('hidden');
$(password_id).closest('.form-group').removeClass('hidden');
$(auto_push_id).closest('.form-group').removeClass('hidden');
$('#command-filter-block').addClass('hidden');
$(command_filter_block_id).addClass('hidden');
$(sudo_id).closest('.form-group').addClass('hidden');
$(shell_id).closest('.form-group').addClass('hidden');
}
else if (['vnc', 'mysql'].indexOf(protocol) !== -1) {
else if (protocol === 'vnc') {
$('.auth-fields').removeClass('hidden');
$(auto_generate_key).closest('.form-group').addClass('hidden');
$(private_key_id).closest('.form-group').addClass('hidden');
$(password_id).closest('.form-group').removeClass('hidden');
$(auto_push_id).closest('.form-group').addClass('hidden');
$('#command-filter-block').addClass('hidden');
$(command_filter_block_id).addClass('hidden');
$(sudo_id).closest('.form-group').addClass('hidden');
$(shell_id).closest('.form-group').addClass('hidden');
}
else if (protocol === 'mysql'){
$('.auth-fields').removeClass('hidden');
$(auto_generate_key).closest('.form-group').addClass('hidden');
$(private_key_id).closest('.form-group').addClass('hidden');
$(password_id).closest('.form-group').removeClass('hidden');
$(auto_push_id).closest('.form-group').addClass('hidden');
$(command_filter_block_id).removeClass('hidden');
$(sudo_id).closest('.form-group').addClass('hidden');
$(shell_id).closest('.form-group').addClass('hidden');
}
@ -121,7 +132,7 @@ function autoLoginModeProtocol() {
$(private_key_id).closest('.form-group').addClass('hidden');
$(password_id).closest('.form-group').removeClass('hidden');
$(auto_push_id).closest('.form-group').addClass('hidden');
$('#command-filter-block').removeClass('hidden');
$(command_filter_block_id).removeClass('hidden');
$(sudo_id).closest('.form-group').addClass('hidden');
$(shell_id).closest('.form-group').addClass('hidden');
}
@ -131,7 +142,7 @@ function autoLoginModeProtocol() {
$(private_key_id).closest('.form-group').removeClass('hidden');
$(password_id).closest('.form-group').removeClass('hidden');
$(auto_push_id).closest('.form-group').removeClass('hidden');
$('#command-filter-block').removeClass('hidden');
$(command_filter_block_id).removeClass('hidden');
$(sudo_id).closest('.form-group').removeClass('hidden');
$(shell_id).closest('.form-group').removeClass('hidden');
}
@ -147,17 +158,27 @@ function manualLoginModeProtocol() {
$(password_id).closest('.form-group').addClass('hidden');
$(private_key_id).closest('.form-group').addClass('hidden');
$(auto_push_id).closest('.form-group').addClass('hidden');
$('#command-filter-block').addClass('hidden');
$(command_filter_block_id).addClass('hidden');
$(sudo_id).closest('.form-group').addClass('hidden');
$(shell_id).closest('.form-group').addClass('hidden');
}
else if (['vnc', 'mysql'].indexOf(protocol) !== -1) {
else if (protocol === 'vnc'){
$('.auth-fields').addClass('hidden');
$(auto_generate_key).closest('.form-group').addClass('hidden');
$(password_id).closest('.form-group').addClass('hidden');
$(private_key_id).closest('.form-group').addClass('hidden');
$(auto_push_id).closest('.form-group').addClass('hidden');
$('#command-filter-block').addClass('hidden');
$(command_filter_block_id).addClass('hidden');
$(sudo_id).closest('.form-group').addClass('hidden');
$(shell_id).closest('.form-group').addClass('hidden');
}
else if (protocol === 'mysql'){
$('.auth-fields').addClass('hidden');
$(auto_generate_key).closest('.form-group').addClass('hidden');
$(password_id).closest('.form-group').addClass('hidden');
$(private_key_id).closest('.form-group').addClass('hidden');
$(auto_push_id).closest('.form-group').addClass('hidden');
$(command_filter_block_id).removeClass('hidden');
$(sudo_id).closest('.form-group').addClass('hidden');
$(shell_id).closest('.form-group').addClass('hidden');
}
@ -167,7 +188,7 @@ function manualLoginModeProtocol() {
$(password_id).closest('.form-group').addClass('hidden');
$(private_key_id).closest('.form-group').addClass('hidden');
$(auto_push_id).closest('.form-group').addClass('hidden');
$('#command-filter-block').removeClass('hidden');
$(command_filter_block_id).removeClass('hidden');
$(sudo_id).closest('.form-group').addClass('hidden');
$(shell_id).closest('.form-group').addClass('hidden');
}
@ -177,7 +198,7 @@ function manualLoginModeProtocol() {
$(password_id).closest('.form-group').addClass('hidden');
$(private_key_id).closest('.form-group').addClass('hidden');
$(auto_push_id).closest('.form-group').addClass('hidden');
$('#command-filter-block').removeClass('hidden');
$(command_filter_block_id).removeClass('hidden');
$(sudo_id).closest('.form-group').removeClass('hidden');
$(shell_id).closest('.form-group').removeClass('hidden');
}

Binary file not shown.

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-06 11:35+0800\n"
"POT-Creation-Date: 2020-01-14 16:52+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"
@ -39,7 +39,7 @@ msgstr "自定义"
#: audits/templates/audits/ftp_log_list.html:75
#: perms/forms/asset_permission.py:89 perms/models/asset_permission.py:80
#: perms/templates/perms/asset_permission_asset.html:53
#: perms/templates/perms/asset_permission_create_update.html:43
#: perms/templates/perms/asset_permission_create_update.html:57
#: perms/templates/perms/asset_permission_list.html:35
#: perms/templates/perms/asset_permission_list.html:87
#: terminal/backends/command/models.py:13 terminal/models.py:178
@ -109,7 +109,7 @@ msgstr "运行参数"
#: applications/templates/applications/user_database_app_list.html:16
#: applications/templates/applications/user_remote_app_list.html:16
#: assets/forms/asset.py:20 assets/forms/domain.py:77 assets/forms/user.py:74
#: assets/forms/user.py:94 assets/models/asset.py:144 assets/models/base.py:27
#: assets/forms/user.py:94 assets/models/asset.py:144 assets/models/base.py:28
#: assets/models/cluster.py:18 assets/models/cmd_filter.py:21
#: assets/models/domain.py:20 assets/models/group.py:20
#: assets/models/label.py:18 assets/templates/assets/_node_detail_modal.html:27
@ -226,7 +226,7 @@ msgstr "数据库"
#: applications/templates/applications/user_database_app_list.html:20
#: applications/templates/applications/user_remote_app_list.html:19
#: assets/models/asset.py:149 assets/models/asset.py:225
#: assets/models/base.py:32 assets/models/cluster.py:29
#: assets/models/base.py:33 assets/models/cluster.py:29
#: assets/models/cmd_filter.py:23 assets/models/cmd_filter.py:56
#: assets/models/domain.py:21 assets/models/domain.py:53
#: assets/models/group.py:23 assets/models/label.py:23
@ -306,7 +306,7 @@ msgstr "参数"
#: applications/models/remote_app.py:39
#: applications/templates/applications/database_app_detail.html:72
#: applications/templates/applications/remote_app_detail.html:68
#: assets/models/asset.py:223 assets/models/base.py:35
#: assets/models/asset.py:223 assets/models/base.py:36
#: assets/models/cluster.py:28 assets/models/cmd_filter.py:26
#: assets/models/cmd_filter.py:59 assets/models/group.py:21
#: assets/templates/assets/admin_user_detail.html:63
@ -333,7 +333,7 @@ msgstr "创建者"
#: applications/models/remote_app.py:42
#: applications/templates/applications/database_app_detail.html:68
#: applications/templates/applications/remote_app_detail.html:64
#: assets/models/asset.py:224 assets/models/base.py:33
#: assets/models/asset.py:224 assets/models/base.py:34
#: assets/models/cluster.py:26 assets/models/domain.py:23
#: assets/models/gathered_user.py:19 assets/models/group.py:22
#: assets/models/label.py:25 assets/templates/assets/admin_user_detail.html:59
@ -382,7 +382,7 @@ msgstr "远程应用"
#: assets/templates/assets/gateway_create_update.html:54
#: assets/templates/assets/label_create_update.html:18
#: assets/templates/assets/platform_create_update.html:20
#: perms/templates/perms/asset_permission_create_update.html:81
#: perms/templates/perms/asset_permission_create_update.html:127
#: perms/templates/perms/database_app_permission_create_update.html:82
#: perms/templates/perms/remote_app_permission_create_update.html:82
#: settings/templates/settings/basic_setting.html:45
@ -426,7 +426,7 @@ msgstr "重置"
#: assets/templates/assets/label_create_update.html:19
#: assets/templates/assets/platform_create_update.html:21
#: audits/templates/audits/login_log_list.html:95
#: perms/templates/perms/asset_permission_create_update.html:82
#: perms/templates/perms/asset_permission_create_update.html:128
#: perms/templates/perms/database_app_permission_create_update.html:83
#: perms/templates/perms/remote_app_permission_create_update.html:83
#: settings/templates/settings/basic_setting.html:46
@ -615,7 +615,7 @@ msgstr "创建数据库应用"
#: ops/templates/ops/task_history.html:63 ops/templates/ops/task_list.html:17
#: perms/forms/asset_permission.py:20
#: perms/templates/perms/asset_permission_asset.html:54
#: perms/templates/perms/asset_permission_create_update.html:48
#: perms/templates/perms/asset_permission_create_update.html:63
#: perms/templates/perms/asset_permission_list.html:39
#: perms/templates/perms/asset_permission_list.html:96
#: perms/templates/perms/asset_permission_user.html:54
@ -708,6 +708,10 @@ msgstr "远程应用详情"
msgid "My RemoteApp"
msgstr "我的远程应用"
#: assets/api/admin_user.py:59
msgid "Deleted failed, There are related assets"
msgstr "删除失败,存在关联资产"
#: assets/api/node.py:61
msgid "You can't update the root node name"
msgstr "不能修改根节点名称"
@ -825,7 +829,7 @@ msgid "SSH gateway support proxy SSH,RDP,VNC"
msgstr "SSH网关支持代理SSH,RDP和VNC"
#: assets/forms/domain.py:78 assets/forms/user.py:75 assets/forms/user.py:95
#: assets/models/base.py:28 assets/models/gathered_user.py:15
#: assets/models/base.py:29 assets/models/gathered_user.py:15
#: assets/templates/assets/_asset_user_auth_update_modal.html:15
#: assets/templates/assets/_asset_user_auth_view_modal.html:21
#: assets/templates/assets/_asset_user_list.html:21
@ -853,7 +857,6 @@ msgstr "SSH网关支持代理SSH,RDP和VNC"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_execution_subtask_list.html:12
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:13
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:25
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:75
msgid "Username"
msgstr "用户名"
@ -888,7 +891,7 @@ msgstr "基础平台"
msgid "Password or private key passphrase"
msgstr "密码或密钥密码"
#: assets/forms/user.py:26 assets/models/base.py:29
#: assets/forms/user.py:26 assets/models/base.py:30
#: assets/serializers/asset_user.py:63
#: assets/templates/assets/_asset_user_auth_update_modal.html:21
#: assets/templates/assets/_asset_user_auth_view_modal.html:27
@ -979,7 +982,6 @@ msgstr "内部的"
#: users/templates/users/user_asset_permission.html:156
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_asset_list.html:50
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:24
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:74
msgid "IP"
msgstr "IP"
@ -997,7 +999,6 @@ msgstr "IP"
#: users/templates/users/user_asset_permission.html:157
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_asset_list.html:49
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:23
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:73
msgid "Hostname"
msgstr "主机名"
@ -1006,6 +1007,7 @@ msgstr "主机名"
#: assets/templates/assets/domain_gateway_list.html:65
#: assets/templates/assets/system_user_detail.html:67
#: assets/templates/assets/system_user_list.html:26
#: terminal/forms/storage.py:152
#: terminal/templates/terminal/session_list.html:29
#: terminal/templates/terminal/session_list.html:73
msgid "Protocol"
@ -1110,22 +1112,21 @@ msgstr "版本"
msgid "AuthBook"
msgstr ""
#: assets/models/base.py:30 xpack/plugins/change_auth_plan/models.py:99
#: assets/models/base.py:31 xpack/plugins/change_auth_plan/models.py:99
#: xpack/plugins/change_auth_plan/models.py:270
msgid "SSH private key"
msgstr "ssh密钥"
#: assets/models/base.py:31 xpack/plugins/change_auth_plan/models.py:102
#: assets/models/base.py:32 xpack/plugins/change_auth_plan/models.py:102
#: xpack/plugins/change_auth_plan/models.py:266
msgid "SSH public key"
msgstr "ssh公钥"
#: assets/models/base.py:34 assets/models/gathered_user.py:20
#: assets/models/base.py:35 assets/models/gathered_user.py:20
#: assets/templates/assets/cmd_filter_detail.html:68 common/mixins/models.py:52
#: ops/models/adhoc.py:49
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:107
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:27
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:79
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:29
msgid "Date updated"
msgstr "更新日期"
@ -1243,18 +1244,17 @@ msgid "Gateway"
msgstr "网关"
#: assets/models/gathered_user.py:16
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:26
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:78
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:28
msgid "Present"
msgstr "存在"
#: assets/models/gathered_user.py:17
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:76
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:26
msgid "Date last login"
msgstr "最后登录日期"
#: assets/models/gathered_user.py:18
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:77
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:27
msgid "IP last login"
msgstr "最后登录IP"
@ -1280,7 +1280,7 @@ msgstr "默认资产组"
#: ops/templates/ops/command_execution_list.html:66
#: perms/forms/asset_permission.py:83 perms/forms/database_app_permission.py:38
#: perms/forms/remote_app_permission.py:40 perms/models/base.py:49
#: perms/templates/perms/asset_permission_create_update.html:39
#: perms/templates/perms/asset_permission_create_update.html:52
#: perms/templates/perms/asset_permission_list.html:33
#: perms/templates/perms/asset_permission_list.html:81
#: perms/templates/perms/database_app_permission_create_update.html:41
@ -1778,7 +1778,7 @@ msgstr "重命名成功"
#: assets/templates/assets/_system_user.html:33
#: assets/templates/assets/asset_create.html:16
#: assets/templates/assets/gateway_create_update.html:33
#: perms/templates/perms/asset_permission_create_update.html:36
#: perms/templates/perms/asset_permission_create_update.html:48
#: perms/templates/perms/database_app_permission_create_update.html:37
#: perms/templates/perms/remote_app_permission_create_update.html:37
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_create_update.html:37
@ -1801,7 +1801,7 @@ msgstr "自动生成密钥"
#: assets/templates/assets/_system_user.html:65
#: assets/templates/assets/asset_create.html:74
#: assets/templates/assets/gateway_create_update.html:49
#: perms/templates/perms/asset_permission_create_update.html:51
#: perms/templates/perms/asset_permission_create_update.html:97
#: perms/templates/perms/database_app_permission_create_update.html:51
#: perms/templates/perms/remote_app_permission_create_update.html:51
#: terminal/templates/terminal/terminal_update.html:38
@ -1943,7 +1943,7 @@ msgstr "创建日期"
#: assets/templates/assets/asset_detail.html:146 authentication/models.py:19
#: authentication/templates/authentication/_access_key_modal.html:32
#: perms/models/base.py:51
#: perms/templates/perms/asset_permission_create_update.html:53
#: perms/templates/perms/asset_permission_create_update.html:99
#: perms/templates/perms/asset_permission_detail.html:115
#: perms/templates/perms/database_app_permission_create_update.html:53
#: perms/templates/perms/database_app_permission_detail.html:111
@ -2516,7 +2516,6 @@ msgstr "日期"
#: audits/templates/audits/login_log_list.html:91
#: templates/_csv_import_export.html:8
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:60
msgid "Export"
msgstr "导出"
@ -3117,7 +3116,7 @@ msgstr "执行历史"
#: ops/templates/ops/adhoc_detail.html:51
#: ops/templates/ops/command_execution_list.html:65
#: ops/templates/ops/task_adhoc.html:57 ops/templates/ops/task_list.html:13
#: terminal/forms/storage.py:152
#: terminal/forms/storage.py:158
msgid "Hosts"
msgstr "主机"
@ -3223,33 +3222,33 @@ msgstr "任务列表"
msgid "Go"
msgstr ""
#: ops/templates/ops/command_execution_create.html:185
#: ops/templates/ops/command_execution_create.html:179
msgid "Selected assets"
msgstr "已选择资产"
#: ops/templates/ops/command_execution_create.html:188
#: ops/templates/ops/command_execution_create.html:182
msgid "In total"
msgstr "总共"
#: ops/templates/ops/command_execution_create.html:225
#: ops/templates/ops/command_execution_create.html:219
msgid ""
"Select the left asset, select the running system user, execute command in "
"batch"
msgstr "选择左侧资产, 选择运行的系统用户,批量执行命令"
#: ops/templates/ops/command_execution_create.html:269
#: ops/templates/ops/command_execution_create.html:263
msgid "Unselected assets"
msgstr "没有选中资产"
#: ops/templates/ops/command_execution_create.html:273
#: ops/templates/ops/command_execution_create.html:267
msgid "No input command"
msgstr "没有输入命令"
#: ops/templates/ops/command_execution_create.html:277
#: ops/templates/ops/command_execution_create.html:271
msgid "No system user was selected"
msgstr "没有选择系统用户"
#: ops/templates/ops/command_execution_create.html:287
#: ops/templates/ops/command_execution_create.html:281
msgid "Pending"
msgstr "等待"
@ -3488,7 +3487,7 @@ msgstr "加入"
msgid "Select system users"
msgstr "选择系统用户"
#: perms/templates/perms/asset_permission_create_update.html:59
#: perms/templates/perms/asset_permission_create_update.html:105
#: perms/templates/perms/database_app_permission_create_update.html:59
#: perms/templates/perms/remote_app_permission_create_update.html:59
msgid "Validity period"
@ -4627,7 +4626,7 @@ msgstr ""
msgid "Region"
msgstr "地域"
#: terminal/forms/storage.py:154
#: terminal/forms/storage.py:160
msgid ""
"\n"
" Tips: If there are multiple hosts, separate them with a comma "
@ -4642,11 +4641,11 @@ msgstr ""
" eg: http://www.jumpserver.a.com,http://www.jumpserver.b.com\n"
" "
#: terminal/forms/storage.py:162
#: terminal/forms/storage.py:168
msgid "Index"
msgstr "索引"
#: terminal/forms/storage.py:165
#: terminal/forms/storage.py:171
msgid "Doc type"
msgstr "文档类型"
@ -6399,7 +6398,6 @@ msgstr "定时执行"
#: xpack/plugins/gathered_user/models.py:57
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:13
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:49
msgid "Gather user task"
msgstr "收集用户任务"
@ -6415,9 +6413,7 @@ msgstr "收集用户执行"
msgid "Assets is empty, please change nodes"
msgstr "资产为空,请更改节点"
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:224
#, fuzzy
#| msgid "Asset users of"
#: xpack/plugins/gathered_user/templates/gathered_user/gathered_user_list.html:170
msgid "Asset user"
msgstr "资产用户"
@ -6530,10 +6526,8 @@ msgid "Enterprise edition"
msgstr "企业版"
#: xpack/plugins/license/models.py:78
#, fuzzy
#| msgid "Enterprise edition"
msgid "Ultimate edition"
msgstr "企业版"
msgstr "旗舰版"
#: xpack/plugins/license/templates/license/_license_import_modal.html:4
#: xpack/plugins/license/templates/license/license_detail.html:86
@ -6653,8 +6647,6 @@ msgid "Import vault"
msgstr "导入密码"
#: xpack/plugins/vault/templates/vault/vault.html:66
#, fuzzy
#| msgid "Vault"
msgid "vault"
msgstr "密码匣子"

View File

@ -84,6 +84,8 @@ class ValidateUserAssetPermissionApi(UserAssetPermissionMixin, APIView):
system_users_actions = self.util.get_asset_system_users_with_actions(
asset)
actions = system_users_actions.get(system_user)
if actions is None:
return Response({'msg': False}, status=403)
if action_name in Action.value_to_choices(actions):
return Response({'msg': True}, status=200)
return Response({'msg': False}, status=403)

View File

@ -4,6 +4,17 @@
{% load bootstrap3 %}
{% block custom_head_css_js %}
<link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet">
<style>
.ul-padding-0 {
padding-inline-start: 0px
}
.ul-padding-20 {
padding-inline-start: 20px
}
ul li{
list-style-type: none;
}
</style>
{% endblock %}
{% block content %}
@ -33,20 +44,55 @@
</div>
{% endif %}
{% csrf_token %}
<h3>{% trans 'Basic' %}</h3>
{% bootstrap_field form.name layout="horizontal" %}
<div class="hr-line-dashed"></div>
<h3>{% trans 'User' %}</h3>
{% bootstrap_field form.users layout="horizontal" %}
{% bootstrap_field form.user_groups layout="horizontal" %}
<div class="hr-line-dashed"></div>
<h3>{% trans 'Asset' %}</h3>
{% bootstrap_field form.assets layout="horizontal" %}
{% bootstrap_field form.nodes layout="horizontal" %}
{% bootstrap_field form.system_users layout="horizontal" %}
<div class="hr-line-dashed"></div>
<h3>{% trans 'Action' %}</h3>
{% bootstrap_field form.actions layout="horizontal" %}
<div class="form-group required">
<label class="col-md-2 control-label">{{ form.actions.label }}</label>
<div class="col-md-9">
<div id="id_actions">
<ul class="ul-padding-0">
<li>
<div class="checkbox">{{ form.actions.0}}</div>
<ul class="ul-padding-20">
<li>
<div class="checkbox">{{ form.actions.1}}</div>
</li>
<li>
<div class="checkbox">{{ form.actions.4}}</div>
<ul class="ul-padding-20">
<li>
<div class="checkbox">{{ form.actions.2}}</div>
</li>
<li>
<div class="checkbox">{{ form.actions.3}}</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="help-block">{{ form.actions.help_text }}</div>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
<h3>{% trans 'Other' %}</h3>
<div class="form-group">
@ -100,6 +146,21 @@
<script>
var api_action = "{{ api_action }}";
var idActionAll = "id_actions_0";
var idActionConnect = "id_actions_1";
var idActionUpload = "id_actions_2";
var idActionDownload = "id_actions_3";
var idActionUpDownload = "id_actions_4";
var elementActionAll = document.getElementById(idActionAll);
var elementActionConnect = document.getElementById(idActionConnect);
var elementActionUpload = document.getElementById(idActionUpload);
var elementActionDownload = document.getElementById(idActionDownload);
var elementActionUpDownload = document.getElementById(idActionUpDownload);
var elementActionUpDownloadChildren = [elementActionUpload, elementActionDownload];
var elementActionAllChildren = [
elementActionConnect, elementActionUpload, elementActionDownload, elementActionUpDownload
];
$(document).ready(function () {
$('.select2').select2({
closeOnSelect: false
@ -110,6 +171,27 @@ $(document).ready(function () {
initDateRangePicker('#date_start');
initDateRangePicker('#date_expired');
initAssetTreeModel('#id_assets');
}).on("change", "input[name=actions]", function (e) {
let idAction = e.target.getAttribute("id");
if (idAction === idActionAll){
$.each(elementActionAllChildren, function(i, elementAction){
elementAction.checked = elementActionAll.checked
});
return;
}
else if (idAction === idActionUpDownload){
$.each(elementActionUpDownloadChildren, function(i, elementAction){
elementAction.checked = elementActionUpDownload.checked
});
}
else if ([idActionUpload, idActionDownload].indexOf(idAction) !== -1){
elementActionUpDownload.checked = elementActionUpload.checked && elementActionDownload.checked
}
let checked = true;
$.each(elementActionAllChildren, function(i, elementAction){
checked &= elementAction.checked;
});
elementActionAll.checked = checked;
})
.on("submit", "form", function (evt) {
evt.preventDefault();
@ -133,6 +215,6 @@ $(document).ready(function () {
redirect_to: redirect_to
};
formSubmit(props);
})
})
</script>
{% endblock %}

View File

@ -56,7 +56,7 @@ class DatabaseAppPermissionUtil:
def get_database_apps(self):
database_apps = DatabaseApp.objects.filter(
granted_by_permissions__in=self.permissions
)
).distinct()
return database_apps
def get_database_app_system_users(self, database_app):

View File

@ -9,7 +9,6 @@ from orgs.utils import set_to_root_org
from ..models import RemoteAppPermission
from ..hands import RemoteApp, SystemUser
__all__ = [
'RemoteAppPermissionUtil',
'construct_remote_apps_tree_root',
@ -56,7 +55,7 @@ class RemoteAppPermissionUtil:
def get_remote_apps(self):
remote_apps = RemoteApp.objects.filter(
granted_by_permissions__in=self.permissions
)
).distinct()
return remote_apps
def get_remote_app_system_users(self, remote_app):

View File

@ -1396,8 +1396,8 @@ function showCeleryTaskLog(taskId) {
}
function getUserLang(){
let userLangZh = document.cookie.indexOf('django_language=zh');
if (userLangZh !== -1){
let userLangZh = document.cookie.indexOf('django_language=en');
if (userLangZh === -1){
return 'zh-CN'
}
else{

View File

@ -1 +1,2 @@
tiff-dev jpeg-dev zlib-dev freetype-dev lcms-dev libwebp-dev tcl-dev tk-dev python3-dev libressl-dev openldap-dev cyrus-sasl-dev krb5-dev sshpass postgresql-dev mariadb-dev sqlite-dev libffi-dev openssh-client gcc libc-dev linux-headers make autoconf
gcc make python3-dev python3 libffi-dev mariadb-dev libc-dev libffi-dev krb5-dev openldap-dev jpeg-dev linux-headers sshpass openssh-client

View File

@ -59,7 +59,7 @@ pytz==2018.3
PyYAML==5.1
redis==2.10.6
requests==2.22.0
jms-storage==0.0.25
jms-storage==0.0.26
s3transfer==0.1.13
simplejson==3.13.2
six==1.11.0