diff options
-rw-r--r-- | archaeological_operations/forms.py | 3 | ||||
-rw-r--r-- | archaeological_operations/views.py | 2 | ||||
-rw-r--r-- | ishtar_common/forms.py | 5 |
3 files changed, 7 insertions, 3 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 4034b94cd..caa19a1fb 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -363,7 +363,8 @@ class ParcelFormSet(FormSet): self.management_form.is_valid() # Checks that no parcels are duplicated. self.check_duplicate(('town', 'section', 'parcel_number', - 'year'), _("There are identical parcels.")) + 'year'), _("There are identical parcels."), + exclude_deleted=True) if hasattr(self, 'cleaned_data') and self.cleaned_data: return self.cleaned_data diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 6208e7265..23419ba14 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -444,7 +444,7 @@ def operation_modify_parcels(request, pk): if request.method == 'POST': new_data = dict(request.POST) - new_data = {k: new_data[k][0] for k in new_data} # convert POST to classic dict + new_data = {k: new_data[k][0] for k in new_data} # convert POST to classic dict new_data.update(data) formset = formset_class(new_data) parcel_selection = new_data.get('_parcel_selection', None) diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 20658d2de..020d54198 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -512,7 +512,8 @@ class FormSet(CustomForm, BaseFormSet): ] super(FormSet, self).__init__(*args, **kwargs) - def check_duplicate(self, key_names, error_msg="", check_null=False): + def check_duplicate(self, key_names, error_msg="", check_null=False, + exclude_deleted=False): """Check for duplicate items in the formset""" if any(self.errors): return @@ -523,6 +524,8 @@ class FormSet(CustomForm, BaseFormSet): form = self.forms[i] if not form.is_valid(): continue + if exclude_deleted and form.cleaned_data.get("DELETE", False): + continue item = [ key_name in form.cleaned_data and form.cleaned_data[key_name] for key_name in key_names |