diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-02-11 01:11:44 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-02-11 01:11:44 +0100 |
commit | 46cc54310a0cbac2d6da4a4a7c7d4ed07b78eac8 (patch) | |
tree | bd3d2aa66f7ca10dfc0fe74675c482d3bc7a1407 /ishtar/furnitures/forms.py | |
parent | 7eac25504c3b76308e37a0b16f6c51986696661e (diff) | |
download | Ishtar-46cc54310a0cbac2d6da4a4a7c7d4ed07b78eac8.tar.bz2 Ishtar-46cc54310a0cbac2d6da4a4a7c7d4ed07b78eac8.zip |
Prevent from adding the same parcel twice (closes #160)
Diffstat (limited to 'ishtar/furnitures/forms.py')
-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) |