diff options
-rw-r--r-- | ishtar/furnitures/forms.py | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index e99d4f077..68c672c01 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -858,22 +858,7 @@ class ParcelForm(forms.Form): class ParcelFormSet(FormSet): def clean(self): """Checks that no parcels are duplicated.""" - if any(self.errors): - return - parcels = [] - for i in range(0, self.total_form_count()): - form = self.forms[i] - if not hasattr(form, 'cleaned_data')\ - or not form.cleaned_data\ - or 'town' not in form.cleaned_data \ - or 'section' not in form.cleaned_data \ - or 'parcel_number' not in form.cleaned_data: - continue - parcel = (form.cleaned_data['town'], form.cleaned_data['section'], - form.cleaned_data['parcel_number']) - if parcel in parcels: - raise forms.ValidationError, _("There are identical parcels.") - parcels.append(parcel) + return clean_duplicated(self, ('town', 'parcel_number', 'year')) ParcelFormSet = formset_factory(ParcelForm, can_delete=True, formset=ParcelFormSet) |