Add serial number field to UPS host
This commit is contained in:
@@ -6,10 +6,11 @@ from .models import UPSHost, Battery
|
|||||||
class UPSHostForm(forms.ModelForm):
|
class UPSHostForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UPSHost
|
model = UPSHost
|
||||||
fields = ['brand', 'model', 'ip_address', 'quantity', 'location', 'last_maintenance_date', 'contact']
|
fields = ['brand', 'model', 'serial_number', 'ip_address', 'quantity', 'location', 'last_maintenance_date', 'contact']
|
||||||
labels = {
|
labels = {
|
||||||
'brand': '品牌',
|
'brand': '品牌',
|
||||||
'model': '型号',
|
'model': '型号',
|
||||||
|
'serial_number': '序列号',
|
||||||
'ip_address': 'IP地址',
|
'ip_address': 'IP地址',
|
||||||
'quantity': '数量',
|
'quantity': '数量',
|
||||||
'location': '存放位置',
|
'location': '存放位置',
|
||||||
@@ -19,6 +20,7 @@ class UPSHostForm(forms.ModelForm):
|
|||||||
widgets = {
|
widgets = {
|
||||||
'brand': forms.TextInput(attrs={'class': 'form-control'}),
|
'brand': forms.TextInput(attrs={'class': 'form-control'}),
|
||||||
'model': forms.TextInput(attrs={'class': 'form-control'}),
|
'model': forms.TextInput(attrs={'class': 'form-control'}),
|
||||||
|
'serial_number': forms.TextInput(attrs={'class': 'form-control'}),
|
||||||
'ip_address': forms.TextInput(attrs={'class': 'form-control'}),
|
'ip_address': forms.TextInput(attrs={'class': 'form-control'}),
|
||||||
'quantity': forms.NumberInput(attrs={'class': 'form-control', 'min': '1'}),
|
'quantity': forms.NumberInput(attrs={'class': 'form-control', 'min': '1'}),
|
||||||
'location': forms.TextInput(attrs={'class': 'form-control'}),
|
'location': forms.TextInput(attrs={'class': 'form-control'}),
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.6 on 2026-05-18 05:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('ups_manager', '0005_alter_upshost_ip_address'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='upshost',
|
||||||
|
name='serial_number',
|
||||||
|
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='序列号'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -36,6 +36,7 @@ class Supplier(models.Model):
|
|||||||
class UPSHost(models.Model):
|
class UPSHost(models.Model):
|
||||||
brand = models.CharField(max_length=100, verbose_name='品牌')
|
brand = models.CharField(max_length=100, verbose_name='品牌')
|
||||||
model = models.CharField(max_length=100, verbose_name='型号')
|
model = models.CharField(max_length=100, verbose_name='型号')
|
||||||
|
serial_number = models.CharField(max_length=100, blank=True, null=True, verbose_name='序列号')
|
||||||
ip_address = models.CharField(max_length=50, blank=True, null=True, verbose_name='IP地址')
|
ip_address = models.CharField(max_length=50, blank=True, null=True, verbose_name='IP地址')
|
||||||
quantity = models.IntegerField(default=1, verbose_name='数量')
|
quantity = models.IntegerField(default=1, verbose_name='数量')
|
||||||
location = models.CharField(max_length=200, verbose_name='存放位置')
|
location = models.CharField(max_length=200, verbose_name='存放位置')
|
||||||
|
|||||||
@@ -40,6 +40,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.serial_number.id_for_label }}" class="form-label font-weight-semibold">
|
||||||
|
{{ form.serial_number.label }}
|
||||||
|
</label>
|
||||||
|
{{ form.serial_number }}
|
||||||
|
{% if form.serial_number.errors %}
|
||||||
|
{% for error in form.serial_number.errors %}
|
||||||
|
<div class="invalid-feedback d-block">{{ error }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="{{ form.ip_address.id_for_label }}" class="form-label font-weight-semibold">
|
<label for="{{ form.ip_address.id_for_label }}" class="form-label font-weight-semibold">
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
<th>主机名称</th>
|
<th>主机名称</th>
|
||||||
<th>品牌</th>
|
<th>品牌</th>
|
||||||
<th>型号</th>
|
<th>型号</th>
|
||||||
|
<th>序列号</th>
|
||||||
<th>IP地址</th>
|
<th>IP地址</th>
|
||||||
<th>数量</th>
|
<th>数量</th>
|
||||||
<th>存放位置</th>
|
<th>存放位置</th>
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
<td>{{ ups.brand }} {{ ups.model }}</td>
|
<td>{{ ups.brand }} {{ ups.model }}</td>
|
||||||
<td>{{ ups.brand }}</td>
|
<td>{{ ups.brand }}</td>
|
||||||
<td>{{ ups.model }}</td>
|
<td>{{ ups.model }}</td>
|
||||||
|
<td>{{ ups.serial_number|default:"-" }}</td>
|
||||||
<td>{{ ups.ip_address }}</td>
|
<td>{{ ups.ip_address }}</td>
|
||||||
<td>{{ ups.quantity }}</td>
|
<td>{{ ups.quantity }}</td>
|
||||||
<td>{{ ups.location }}</td>
|
<td>{{ ups.location }}</td>
|
||||||
@@ -62,7 +64,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="11" class="text-center text-muted">暂无UPS主机记录</td>
|
<td colspan="12" class="text-center text-muted">暂无UPS主机记录</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user