mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Validation of power reqs
This commit is contained in:
@@ -173,6 +173,12 @@ class EventRiskAssessmentForm(forms.ModelForm):
|
||||
|
||||
|
||||
class EventChecklistForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EventChecklistForm, self).__init__(*args, **kwargs)
|
||||
for name, field in self.fields.items():
|
||||
if field.__class__ == forms.NullBooleanField:
|
||||
# Only display yes/no to user, the 'none' is only ever set in the background
|
||||
field.widget = forms.CheckboxInput()
|
||||
# Parsed from incoming form data by clean, then saved into models when the form is saved
|
||||
items = {}
|
||||
|
||||
@@ -231,6 +237,7 @@ class EventChecklistForm(forms.ModelForm):
|
||||
# Remove all existing, to be recreated from the form
|
||||
checklist.vehicles.all().delete()
|
||||
checklist.crew.all().delete()
|
||||
checklist.save()
|
||||
|
||||
for key in self.items:
|
||||
item = self.items[key]
|
||||
@@ -240,8 +247,6 @@ class EventChecklistForm(forms.ModelForm):
|
||||
item.full_clean()
|
||||
item.save()
|
||||
|
||||
checklist.save()
|
||||
|
||||
self.items.clear()
|
||||
|
||||
return checklist
|
||||
|
||||
Reference in New Issue
Block a user