CHANGE: Prevent both person and org being left blank for a Rig

Of course, there's no requirement that either of those have any actual contact details...

Closes #276.
This commit is contained in:
2020-01-14 18:10:37 +00:00
parent 10add5ab33
commit 295397b32d

View File

@@ -129,6 +129,11 @@ class EventForm(forms.ModelForm):
return item return item
def clean(self):
if self.cleaned_data.get("is_rig") and not (self.cleaned_data.get('person') or self.cleaned_data.get('organisation')):
raise forms.ValidationError('You haven\'t provided any client contact details. Please add a person or organisation.', code='contact')
return super(EventForm, self).clean()
def save(self, commit=True): def save(self, commit=True):
m = super(EventForm, self).save(commit=False) m = super(EventForm, self).save(commit=False)