From c931d3179bf7725622b8e563dad3e3420733bb49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B3=E4=B9=A6=E5=83=AE?= Date: Fri, 24 Mar 2017 11:02:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B5=84=E4=BA=A7=E7=BB=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=AD=20=E7=94=A8=E6=88=B7=E5=B7=B1?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=9A=84=E8=B5=84=E4=BA=A7=E9=A1=B9=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/assets/asset_modal_list.html | 10 +++++----- apps/assets/views.py | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/assets/templates/assets/asset_modal_list.html b/apps/assets/templates/assets/asset_modal_list.html index 5f86a00e1..bd0147fb6 100644 --- a/apps/assets/templates/assets/asset_modal_list.html +++ b/apps/assets/templates/assets/asset_modal_list.html @@ -18,7 +18,7 @@ - {% for asset in asset_modal_list %} + {% for asset in assets %} {% if asset.id in all_assets %} @@ -26,10 +26,10 @@ {% endif %} - {{ asset.id }} - {{ asset.hostname }} - {{ asset.ip }} - {{ asset.env }}-{{ asset.type }} + {{ asset.id }} + {{ asset.hostname }} + {{ asset.ip }} + {{ asset.env }}-{{ asset.type }} {% endfor %} diff --git a/apps/assets/views.py b/apps/assets/views.py index 1b848a1cf..e89500c75 100644 --- a/apps/assets/views.py +++ b/apps/assets/views.py @@ -195,6 +195,7 @@ class AssetModalListView(AdminUserRequiredMixin, ListView): tag_id = self.request.GET.get('tag_id') plain_id_lists = self.request.GET.get('plain_id_lists') self.s = self.request.GET.get('plain_id_lists') + assets = Asset.objects.all() if "," in str(self.s): self.plain_id_lists = [int(x) for x in self.s.split(',')] else: @@ -206,19 +207,28 @@ class AssetModalListView(AdminUserRequiredMixin, ListView): else: plain_id_lists = [int(self.s)] context = { - 'all_assets': plain_id_lists + 'all_assets': plain_id_lists, + 'assets': assets } kwargs.update(context) if group_id: group = AssetGroup.objects.get(id=group_id) + print group context = { - 'all_assets': [x.id for x in group.assets.all()] + 'all_assets': [x.id for x in group.assets.all()], + 'assets': assets } kwargs.update(context) if tag_id: tag = Tag.objects.get(id=tag_id) context = { - 'all_assets': [x.id for x in tag.asset_set.all()] + 'all_assets': [x.id for x in tag.asset_set.all()], + 'assets': assets + } + kwargs.update(context) + else: + context = { + 'assets': assets } kwargs.update(context) return super(AssetModalListView, self).get_context_data(**kwargs) -- GitLab