From d40d231e9a59885cd38a17c4f5227668558d317a Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 9 Jul 2019 19:58:16 +0800 Subject: [PATCH 1/6] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9assets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/templates/assets/_node_tree.html | 48 -------------------- apps/assets/templates/assets/asset_list.html | 39 ++++++++++++++-- 2 files changed, 36 insertions(+), 51 deletions(-) diff --git a/apps/assets/templates/assets/_node_tree.html b/apps/assets/templates/assets/_node_tree.html index 93aed7d89..61737184c 100644 --- a/apps/assets/templates/assets/_node_tree.html +++ b/apps/assets/templates/assets/_node_tree.html @@ -291,42 +291,6 @@ function defaultCallback(action) { $(document).ready(function () { }) -.on('click', '.btn-refresh-hardware', function () { - var url = "{% url 'api-assets:node-refresh-hardware-info' pk=DEFAULT_PK %}"; - var the_url = url.replace("{{ DEFAULT_PK }}", current_node_id); - function success(data) { - rMenu.css({"visibility" : "hidden"}); - var task_id = data.task; - var url = '{% url "ops:celery-task-log" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", task_id); - window.open(url, '', 'width=800,height=600') - } - APIUpdateAttr({ - url: the_url, - method: "GET", - success: success, - flash_message: false - }); - -}) -.on('click', '.btn-test-connective', function () { - var url = "{% url 'api-assets:node-test-connective' pk=DEFAULT_PK %}"; - if (!current_node_id) { - return null; - } - var the_url = url.replace("{{ DEFAULT_PK }}", current_node_id); - function success(data) { - rMenu.css({"visibility" : "hidden"}); - var task_id = data.task; - var url = '{% url "ops:celery-task-log" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", task_id); - window.open(url, '', 'width=800,height=600') - } - APIUpdateAttr({ - url: the_url, - method: "GET", - success: success, - flash_message: false - }); -}) .on('click', '.btn-show-current-asset', function(){ hideRMenu(); $(this).css('display', 'none'); @@ -341,17 +305,5 @@ $(document).ready(function () { setCookie('show_current_asset', ''); location.reload(); }) -.on('click', '.btn-test-connective', function () { - hideRMenu(); -}) -.on('click', '#menu_refresh_assets_amount', function () { - hideRMenu(); - var url = "{% url 'api-assets:refresh-assets-amount' %}"; - APIUpdateAttr({ - 'url': url, - 'method': 'GET' - }); - window.location.reload(); -}) \ No newline at end of file diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html index 3b9df3373..8f889feb7 100644 --- a/apps/assets/templates/assets/asset_list.html +++ b/apps/assets/templates/assets/asset_list.html @@ -167,7 +167,7 @@ function initTable() { }}, {targets: 5, createdCell: function (td, cellData, rowData) { var update_btn = '{% trans "Update" %}'.replace("{{ DEFAULT_PK }}", cellData); - var del_btn = '{% trans "Delete" %}'.replace('{{ DEFAULT_PK }}', cellData); + var del_btn = '{% trans "Delete" %}'.replace('{{ DEFAULT_PK }}', cellData); $(td).html(update_btn + del_btn) }} ], @@ -325,8 +325,7 @@ $(document).ready(function(){ } window.open(url, '_self'); }) - -.on('click', '.btn_asset_delete', function () { +.on('click', '.btn-asset-delete', function () { var $this = $(this); var $data_table = $("#asset_list_table").DataTable(); var name = $(this).closest("tr").find(":nth-child(2)").children('a').html(); @@ -513,6 +512,40 @@ $(document).ready(function(){ update_node_action = "add" }).on('click', '#menu_asset_move', function () { update_node_action = "move" +}).on('click', '.btn-test-connective', function () { + var url = "{% url 'api-assets:node-test-connective' pk=DEFAULT_PK %}"; + if (!current_node_id) { + return null; + } + var the_url = url.replace("{{ DEFAULT_PK }}", current_node_id); + function success(data) { + rMenu.css({"visibility" : "hidden"}); + var task_id = data.task; + var url = '{% url "ops:celery-task-log" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", task_id); + window.open(url, '', 'width=800,height=600') + } + APIUpdateAttr({ + url: the_url, + method: "GET", + success: success, + flash_message: false + }); +}).on('click', '.btn-refresh-hardware', function () { + var url = "{% url 'api-assets:node-refresh-hardware-info' pk=DEFAULT_PK %}"; + var the_url = url.replace("{{ DEFAULT_PK }}", current_node_id); + function success(data) { + rMenu.css({"visibility" : "hidden"}); + var task_id = data.task; + var url = '{% url "ops:celery-task-log" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", task_id); + window.open(url, '', 'width=800,height=600') + } + APIUpdateAttr({ + url: the_url, + method: "GET", + success: success, + flash_message: false + }); + }) From 6cf11ab411dfae2bcf144fdd039d041ce4d8df9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AB=E5=8D=83=E6=B5=81?= <40739051+jym503558564@users.noreply.github.com> Date: Mon, 15 Jul 2019 15:38:34 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[Update]=20=E4=BC=98=E5=8C=96mfa=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E8=BA=AB=E4=BB=BD=E9=A1=B5=E9=9D=A2=E6=B0=B4=E5=B9=B3?= =?UTF-8?q?=E7=BA=BF=E5=9C=A8=E5=A4=A7=E5=B1=8F=E5=B9=95=E6=97=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=AF=B9=E5=85=B6=E9=97=AE=E9=A2=98=20(#2948)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Update] 优化mfa验证身份页面水平线在大屏幕无自动对其问题 * [Update] 修改小问题 --- apps/users/templates/users/_base_otp.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/users/templates/users/_base_otp.html b/apps/users/templates/users/_base_otp.html index b45758afc..0bb257239 100644 --- a/apps/users/templates/users/_base_otp.html +++ b/apps/users/templates/users/_base_otp.html @@ -42,8 +42,7 @@
{% trans 'Security token validation' %}  {% trans 'Account' %} {{ user.username }}  {% trans 'Follow these steps to complete the binding operation' %}
-
- +
{% block content %} {% endblock %}
From a884d0d53196df2ba92d68768c4f64915496fe9a Mon Sep 17 00:00:00 2001 From: BaiJiangJie <32935519+BaiJiangJie@users.noreply.github.com> Date: Mon, 15 Jul 2019 18:47:17 +0800 Subject: [PATCH 3/6] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E6=94=B9Bug=20(#2952)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Bugfix] 取消管理用户列表按资产数量字段排序 * [Bugfix] 修复后去用户资产权限动作的Bug --- apps/assets/templates/assets/admin_user_list.html | 2 +- apps/perms/api/user_permission.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/assets/templates/assets/admin_user_list.html b/apps/assets/templates/assets/admin_user_list.html index 61389ad08..2212fd82f 100644 --- a/apps/assets/templates/assets/admin_user_list.html +++ b/apps/assets/templates/assets/admin_user_list.html @@ -115,7 +115,7 @@ function initTable() { }}], ajax_url: '{% url "api-assets:admin-user-list" %}', columns: [ - {data: function(){return ""}}, {data: "name"}, {data: "username" }, {data: "assets_amount" }, + {data: function(){return ""}}, {data: "name"}, {data: "username" }, {data: "assets_amount", orderable: false}, {#{data: "connectivity_amount"}, {data: "connectivity_amount"}, {data: "connectivity_amount"},#} {data: "comment"}, {data: "id"} ] diff --git a/apps/perms/api/user_permission.py b/apps/perms/api/user_permission.py index 0e67e2747..0746252cb 100644 --- a/apps/perms/api/user_permission.py +++ b/apps/perms/api/user_permission.py @@ -344,6 +344,12 @@ class GetUserAssetPermissionActionsApi(UserPermissionCacheMixin, RetrieveAPIView user_id = self.request.query_params.get('user_id', '') asset_id = self.request.query_params.get('asset_id', '') system_id = self.request.query_params.get('system_user_id', '') + try: + user_id = uuid.UUID(user_id) + asset_id = uuid.UUID(asset_id) + system_id = uuid.UUID(system_id) + except ValueError: + return Response({'msg': False}, status=403) user = get_object_or_404(User, id=user_id) From 6f2f025b04804020cf55df5f8dcb8b9672a4cded Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Mon, 15 Jul 2019 19:02:00 +0800 Subject: [PATCH 4/6] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E6=94=B9=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=E5=88=97=E8=A1=A8=E6=95=B0=E9=87=8F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/asset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/assets/api/asset.py b/apps/assets/api/asset.py index 2d22dd41b..bdf5b8d89 100644 --- a/apps/assets/api/asset.py +++ b/apps/assets/api/asset.py @@ -85,7 +85,7 @@ class AssetViewSet(LabelFilter, OrgBulkModelViewSet): queryset = queryset.filter( nodes__key__regex='^{}(:[0-9]+)*$'.format(node.key), ) - return queryset + return queryset.distinct() def filter_admin_user_id(self, queryset): admin_user_id = self.request.query_params.get('admin_user_id') From ab520ee345c91189ab10709b15bab47df94c4ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AB=E5=8D=83=E6=B5=81?= <40739051+jym503558564@users.noreply.github.com> Date: Tue, 16 Jul 2019 10:03:00 +0800 Subject: [PATCH 5/6] =?UTF-8?q?[Bugfix]=20=E7=BC=BA=E5=B0=91=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E7=BF=BB=E8=AF=91=20(#2956)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/forms/cmd_filter.py | 1 + apps/assets/serializers/cmd_filter.py | 1 + 2 files changed, 2 insertions(+) diff --git a/apps/assets/forms/cmd_filter.py b/apps/assets/forms/cmd_filter.py index 308a008d0..cd7df89e8 100644 --- a/apps/assets/forms/cmd_filter.py +++ b/apps/assets/forms/cmd_filter.py @@ -2,6 +2,7 @@ # from django import forms from django.core.exceptions import ValidationError +from django.utils.translation import ugettext_lazy as _ import re from orgs.mixins import OrgModelForm diff --git a/apps/assets/serializers/cmd_filter.py b/apps/assets/serializers/cmd_filter.py index dfdff2cdb..6be0eb466 100644 --- a/apps/assets/serializers/cmd_filter.py +++ b/apps/assets/serializers/cmd_filter.py @@ -2,6 +2,7 @@ # import re from rest_framework import serializers +from django.utils.translation import ugettext_lazy as _ from common.fields import ChoiceDisplayField from common.serializers import AdaptedBulkListSerializer From 875a069a18fa5b7318f55617baa2828f0ae8b241 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 16 Jul 2019 10:09:36 +0800 Subject: [PATCH 6/6] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/serializers/cmd_filter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/assets/serializers/cmd_filter.py b/apps/assets/serializers/cmd_filter.py index 6be0eb466..3f29ca686 100644 --- a/apps/assets/serializers/cmd_filter.py +++ b/apps/assets/serializers/cmd_filter.py @@ -36,6 +36,9 @@ class CommandFilterRuleSerializer(BulkOrgResourceModelSerializer): list_serializer_class = AdaptedBulkListSerializer def validate_content(self, content): + tp = self.initial_data.get("type") + if tp == CommandFilterRule.TYPE_REGEX: + return content if self.invalid_pattern.search(content): invalid_char = self.invalid_pattern.pattern.replace('\\', '') msg = _("Content should not be contain: {}").format(invalid_char)