Add battery count column to UPS host list

This commit is contained in:
xiaji
2026-04-30 14:16:45 +08:00
parent a9f93244fd
commit d33bf1c450
2 changed files with 4 additions and 2 deletions

View File

@@ -36,6 +36,7 @@
<th>IP地址</th>
<th>数量</th>
<th>存放位置</th>
<th>电池数量</th>
<th>上次维保时间</th>
<th>联系人</th>
<th>操作</th>
@@ -51,6 +52,7 @@
<td>{{ ups.ip_address }}</td>
<td>{{ ups.quantity }}</td>
<td>{{ ups.location }}</td>
<td><span class="badge bg-success">{{ ups.battery_set.count }}</span></td>
<td>{{ ups.last_maintenance_date|default:"-" }}</td>
<td>{{ ups.contact|default:"-" }}</td>
<td>
@@ -60,7 +62,7 @@
</tr>
{% empty %}
<tr>
<td colspan="10" class="text-center text-muted">暂无UPS主机记录</td>
<td colspan="11" class="text-center text-muted">暂无UPS主机记录</td>
</tr>
{% endfor %}
</tbody>

View File

@@ -78,7 +78,7 @@ class UPSHostListView(ListView):
paginate_by = 10
def get_queryset(self):
queryset = super().get_queryset()
queryset = super().get_queryset().prefetch_related('battery_set')
brand = self.request.GET.get('brand')
model = self.request.GET.get('model')
location = self.request.GET.get('location')