Split maintenance into host and battery types with separate forms
This commit is contained in:
@@ -285,17 +285,32 @@ class MaintenanceListView(ListView):
|
||||
return queryset.order_by('-maintenance_date')
|
||||
|
||||
|
||||
class MaintenanceCreateView(CreateView):
|
||||
class HostMaintenanceCreateView(CreateView):
|
||||
model = MaintenanceRecord
|
||||
template_name = 'ups_manager/maintenance_form.html'
|
||||
template_name = 'ups_manager/host_maintenance_form.html'
|
||||
fields = ['ups_host', 'supplier', 'maintenance_date', 'technician', 'content']
|
||||
success_url = reverse_lazy('maintenance_list')
|
||||
|
||||
def form_valid(self, form):
|
||||
form.instance.maintenance_type = 'host'
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class BatteryMaintenanceCreateView(CreateView):
|
||||
model = MaintenanceRecord
|
||||
template_name = 'ups_manager/battery_maintenance_form.html'
|
||||
fields = ['ups_host', 'battery', 'supplier', 'maintenance_date', 'technician', 'content']
|
||||
success_url = reverse_lazy('maintenance_list')
|
||||
|
||||
def form_valid(self, form):
|
||||
form.instance.maintenance_type = 'battery'
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class MaintenanceUpdateView(UpdateView):
|
||||
model = MaintenanceRecord
|
||||
template_name = 'ups_manager/maintenance_form.html'
|
||||
fields = ['ups_host', 'supplier', 'maintenance_date', 'technician', 'content']
|
||||
fields = ['ups_host', 'battery', 'supplier', 'maintenance_date', 'technician', 'content']
|
||||
success_url = reverse_lazy('maintenance_list')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user