From 295397b32dab699f0ea1fb05980eaecf990c58e5 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Tue, 14 Jan 2020 18:10:37 +0000 Subject: [PATCH] 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. --- RIGS/forms.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RIGS/forms.py b/RIGS/forms.py index 7bd9675b..47b0f062 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -129,6 +129,11 @@ class EventForm(forms.ModelForm): 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): m = super(EventForm, self).save(commit=False)