summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-03-07 19:21:56 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:21:00 +0100
commitf1ae9d46287bdc6eeda3e7c2da6efcbacf422ef9 (patch)
treed03aa242f49bd332b0d87e1907bf38e65169995e
parent1f2b22be5f6ac94ef39d9a6957b2f452b81c92ea (diff)
downloadIshtar-f1ae9d46287bdc6eeda3e7c2da6efcbacf422ef9.tar.bz2
Ishtar-f1ae9d46287bdc6eeda3e7c2da6efcbacf422ef9.zip
Operation - Parcels - Modify: do not check for identical on deleted forms
-rw-r--r--archaeological_operations/forms.py3
-rw-r--r--archaeological_operations/views.py2
-rw-r--r--ishtar_common/forms.py5
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