diff --git a/ups_management/db.sqlite3 b/ups_management/db.sqlite3 index 59c4acd..d1d2b2c 100644 Binary files a/ups_management/db.sqlite3 and b/ups_management/db.sqlite3 differ diff --git a/ups_management/ups_management/__pycache__/settings.cpython-311.pyc b/ups_management/ups_management/__pycache__/settings.cpython-311.pyc index d9972fd..f2f8587 100644 Binary files a/ups_management/ups_management/__pycache__/settings.cpython-311.pyc and b/ups_management/ups_management/__pycache__/settings.cpython-311.pyc differ diff --git a/ups_management/ups_management/__pycache__/urls.cpython-311.pyc b/ups_management/ups_management/__pycache__/urls.cpython-311.pyc index 7e908f1..949bdd7 100644 Binary files a/ups_management/ups_management/__pycache__/urls.cpython-311.pyc and b/ups_management/ups_management/__pycache__/urls.cpython-311.pyc differ diff --git a/ups_management/ups_manager/__pycache__/forms.cpython-311.pyc b/ups_management/ups_manager/__pycache__/forms.cpython-311.pyc new file mode 100644 index 0000000..6d30c99 Binary files /dev/null and b/ups_management/ups_manager/__pycache__/forms.cpython-311.pyc differ diff --git a/ups_management/ups_manager/__pycache__/models.cpython-311.pyc b/ups_management/ups_manager/__pycache__/models.cpython-311.pyc index 5d99660..09eaefd 100644 Binary files a/ups_management/ups_manager/__pycache__/models.cpython-311.pyc and b/ups_management/ups_manager/__pycache__/models.cpython-311.pyc differ diff --git a/ups_management/ups_manager/__pycache__/urls.cpython-311.pyc b/ups_management/ups_manager/__pycache__/urls.cpython-311.pyc index 07b5f62..9fd6679 100644 Binary files a/ups_management/ups_manager/__pycache__/urls.cpython-311.pyc and b/ups_management/ups_manager/__pycache__/urls.cpython-311.pyc differ diff --git a/ups_management/ups_manager/__pycache__/views.cpython-311.pyc b/ups_management/ups_manager/__pycache__/views.cpython-311.pyc index 19ff530..2c5eb34 100644 Binary files a/ups_management/ups_manager/__pycache__/views.cpython-311.pyc and b/ups_management/ups_manager/__pycache__/views.cpython-311.pyc differ diff --git a/ups_management/ups_manager/migrations/0004_maintenancerecord_maintenance_type.py b/ups_management/ups_manager/migrations/0004_maintenancerecord_maintenance_type.py new file mode 100644 index 0000000..4c49edc --- /dev/null +++ b/ups_management/ups_manager/migrations/0004_maintenancerecord_maintenance_type.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.6 on 2026-05-18 03:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ups_manager', '0003_alter_upshost_brand'), + ] + + operations = [ + migrations.AddField( + model_name='maintenancerecord', + name='maintenance_type', + field=models.CharField(choices=[('host', '主机维修'), ('battery', '电池维修')], default='host', max_length=20, verbose_name='维修类型'), + ), + ] diff --git a/ups_management/ups_manager/migrations/__pycache__/0004_maintenancerecord_maintenance_type.cpython-311.pyc b/ups_management/ups_manager/migrations/__pycache__/0004_maintenancerecord_maintenance_type.cpython-311.pyc new file mode 100644 index 0000000..0821500 Binary files /dev/null and b/ups_management/ups_manager/migrations/__pycache__/0004_maintenancerecord_maintenance_type.cpython-311.pyc differ diff --git a/ups_management/ups_manager/models.py b/ups_management/ups_manager/models.py index 8168565..569f9fc 100644 --- a/ups_management/ups_manager/models.py +++ b/ups_management/ups_manager/models.py @@ -90,6 +90,12 @@ class Battery(models.Model): class MaintenanceRecord(models.Model): + MAINTENANCE_TYPE_CHOICES = [ + ('host', '主机维修'), + ('battery', '电池维修'), + ] + + maintenance_type = models.CharField(max_length=20, choices=MAINTENANCE_TYPE_CHOICES, default='host', verbose_name='维修类型') ups_host = models.ForeignKey(UPSHost, on_delete=models.CASCADE, verbose_name='UPS主机') battery = models.ForeignKey(Battery, on_delete=models.SET_NULL, blank=True, null=True, verbose_name='电池') supplier = models.ForeignKey(Supplier, on_delete=models.SET_NULL, blank=True, null=True, verbose_name='维保供应商') @@ -99,7 +105,7 @@ class MaintenanceRecord(models.Model): created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') def __str__(self): - return f'{self.ups_host} - {self.maintenance_date}' + return f'{self.get_maintenance_type_display()} - {self.ups_host} - {self.maintenance_date}' class Meta: verbose_name = '维修记录' diff --git a/ups_management/ups_manager/templates/ups_manager/battery_maintenance_form.html b/ups_management/ups_manager/templates/ups_manager/battery_maintenance_form.html new file mode 100644 index 0000000..25a9d73 --- /dev/null +++ b/ups_management/ups_manager/templates/ups_manager/battery_maintenance_form.html @@ -0,0 +1,155 @@ +{% extends 'ups_manager/base.html' %} + +{% block content %} +