From e91a151d549bfc06cb27772e717b80412a39ff61 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 4 Mar 2016 15:20:35 +0100 Subject: Operations: check relations form --- archaeological_operations/forms.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'archaeological_operations/forms.py') diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 69f8e3bdb..8c72222cd 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -365,6 +365,17 @@ class RecordRelationsForm(forms.Form): for rel, opes in nc]) return rendered + def clean(self): + cleaned_data = self.cleaned_data + if (cleaned_data.get('relation_type', None) and + not cleaned_data.get('right_record', None)): + raise forms.ValidationError(_(u"You should select an operation.")) + if (not cleaned_data.get('relation_type', None) and + cleaned_data.get('right_record', None)): + raise forms.ValidationError( + _(u"You should select a relation type.")) + return cleaned_data + @classmethod def get_formated_datas(cls, cleaned_datas): result, current, deleted = [], [], [] -- cgit v1.2.3