Browse Source

修复资产组更新中 用户己选择的资产项不全问题

pull/417/head
右书僮 8 years ago
parent
commit
c931d3179b
  1. 10
      apps/assets/templates/assets/asset_modal_list.html
  2. 16
      apps/assets/views.py

10
apps/assets/templates/assets/asset_modal_list.html

@ -18,7 +18,7 @@
</tr>
</thead>
<tbody>
{% for asset in asset_modal_list %}
{% for asset in assets %}
{% if asset.id in all_assets %}
<tr name="oAssets" class="odd selected text-center">
<td class="text-center" ><input type="checkbox" name="checked" value="{{ asset.id }}" checked="checked"></td>
@ -26,10 +26,10 @@
<tr name="oAssets">
<td class="text-center"><input type="checkbox" name="checked" value="{{ asset.id }}" ></td>
{% endif %}
<td>{{ asset.id }}</td>
<td>{{ asset.hostname }}</td>
<td>{{ asset.ip }}</td>
<td>{{ asset.env }}-{{ asset.type }}</td>
<td class="text-center">{{ asset.id }}</td>
<td class="text-center">{{ asset.hostname }}</td>
<td class="text-center">{{ asset.ip }}</td>
<td class="text-center">{{ asset.env }}-{{ asset.type }}</td>
</tr>
{% endfor %}
</tbody>

16
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)

Loading…
Cancel
Save