From f87db2f4fc281b898dd2f4f7c780fbfe54672c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=B9=BF?= Date: Thu, 26 Sep 2019 10:32:39 +0800 Subject: [PATCH] Bugfix (#3284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Update] 用户资产页面链接是 新窗口打开 * [Bugfix] 修复切换组织时, refer为空导致的bug * [Update] 修复执行命令时报错 --- .../templates/applications/user_remote_app_list.html | 2 +- apps/assets/templates/assets/user_asset_list.html | 4 ++-- apps/assets/utils.py | 4 ---- apps/orgs/views.py | 2 +- apps/perms/utils/asset_permission.py | 5 +++-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/apps/applications/templates/applications/user_remote_app_list.html b/apps/applications/templates/applications/user_remote_app_list.html index a771e647a..576c7ed14 100644 --- a/apps/applications/templates/applications/user_remote_app_list.html +++ b/apps/applications/templates/applications/user_remote_app_list.html @@ -49,7 +49,7 @@ function initTable() { $(td).html(hostname); }}, {targets: 5, createdCell: function (td, cellData, rowData) { - var conn_btn = '{% trans "Connect" %}'.replace("{{ DEFAULT_PK }}", cellData); + var conn_btn = '{% trans "Connect" %}'.replace("{{ DEFAULT_PK }}", cellData); $(td).html(conn_btn) }} ], diff --git a/apps/assets/templates/assets/user_asset_list.html b/apps/assets/templates/assets/user_asset_list.html index a158244a5..7e452eaf6 100644 --- a/apps/assets/templates/assets/user_asset_list.html +++ b/apps/assets/templates/assets/user_asset_list.html @@ -29,7 +29,7 @@ var showAssetHref = false; // Need input default true var actions = { targets: 4, createdCell: function (td, cellData) { var conn_btn = '{% trans "Connect" %}'; + '" class="btn btn-xs btn-primary" target="_blank">{% trans "Connect" %}'; $(td).html(conn_btn) }}; $(document).ready(function () { @@ -85,4 +85,4 @@ function toggle() { } -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/apps/assets/utils.py b/apps/assets/utils.py index 305bcbf36..3ea66ba6c 100644 --- a/apps/assets/utils.py +++ b/apps/assets/utils.py @@ -54,10 +54,6 @@ class TreeService(Tree): tree.init_assets() return tree - def init_assets_async(self): - t = threading.Thread(target=self.init_assets) - t.start() - def init_assets(self): from orgs.utils import tmp_to_root_org self.all_nodes_assets_map = {} diff --git a/apps/orgs/views.py b/apps/orgs/views.py index 01715106d..d599fbab3 100644 --- a/apps/orgs/views.py +++ b/apps/orgs/views.py @@ -17,7 +17,7 @@ class SwitchOrgView(DetailView): oid = str(self.object.id) request.session['oid'] = oid host = request.get_host() - referer = request.META.get('HTTP_REFERER') + referer = request.META.get('HTTP_REFERER', '') if referer.find(host) == -1: return redirect(reverse('index')) if UUID_PATTERN.search(referer): diff --git a/apps/perms/utils/asset_permission.py b/apps/perms/utils/asset_permission.py index b23e31e8b..21b9d8094 100644 --- a/apps/perms/utils/asset_permission.py +++ b/apps/perms/utils/asset_permission.py @@ -158,9 +158,10 @@ class AssetPermissionUtilV2(AssetPermissionUtilCacheMixin): @timeit def filter_permissions(self, **filters): - filters_json = json.dumps(filters, sort_keys=True) + self.cache_policy = '0' + # filters_json = json.dumps(filters, sort_keys=True) self._permissions = self.permissions.filter(**filters) - self._filter_id = md5(filters_json.encode()).hexdigest() + # self._filter_id = md5(filters_json.encode()).hexdigest() @lazyproperty def user_tree(self):