summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-02-07 17:42:34 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:21:00 +0100
commit229cae61256fe29b21c7e04d68e60913549b79fc (patch)
tree818672cfd531bf2bf4e22098a0aa07e6f1ecb8a9
parentdfafbbe9ac104da6cc676ab379659ca60e7fc02c (diff)
downloadIshtar-229cae61256fe29b21c7e04d68e60913549b79fc.tar.bz2
Ishtar-229cae61256fe29b21c7e04d68e60913549b79fc.zip
Operation - Parcels - Modify: fix formset test
-rw-r--r--archaeological_operations/tests.py15
-rw-r--r--archaeological_operations/views.py5
2 files changed, 16 insertions, 4 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index a4ac40376..e5e629884 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -1679,7 +1679,17 @@ class ParcelTest(ImportTest, TestCase):
self.assertContains(response, parcel_1.parcel_number)
self.assertContains(response, parcel_2.parcel_number)
- data = {
+ data = {}
+ for idx in range(2 + views.PARCEL_FORMSET_EXTRA_FORM):
+ data.update({
+ f"form-{idx}-pk": "",
+ f"form-{idx}-year": "",
+ f"form-{idx}-section": "",
+ f"form-{idx}-parcel_number": "",
+ f"form-{idx}-town": town_1.pk,
+ f"form-{idx}-DELETE": '',
+ })
+ data.update({
"form-0-pk": parcel_1.pk,
"form-0-year": 2021,
"form-0-section": "SCT1",
@@ -1694,7 +1704,7 @@ class ParcelTest(ImportTest, TestCase):
"form-2-section": "XXX",
"form-2-parcel_number": "003",
"form-2-town": town_2.pk,
- }
+ })
post_response = c.post("/operation-parcels-modify/" + str(operation.pk) + "/", data)
self.assertEqual(post_response.status_code, 200)
@@ -1719,7 +1729,6 @@ class ParcelTest(ImportTest, TestCase):
self.assertContains(response, "001", count=0)
deleted_parcel = models.Parcel.objects.filter(pk=parcel_1.pk)
- print(deleted_parcel)
self.assertEqual(deleted_parcel.count(), 0)
def create_orga(user):
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index 647f4b485..0cd1cd8cf 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -409,6 +409,9 @@ def operation_delete(request, pk):
return redirect(reverse(wizard_url, kwargs={"step": "final-" + wizard_url}))
+PARCEL_FORMSET_EXTRA_FORM = 3
+
+
def operation_modify_parcels(request, pk):
formset_class = SelectedParcelGeneralFormSet
operation = models.Operation.objects.get(pk=pk)
@@ -432,7 +435,7 @@ def operation_modify_parcels(request, pk):
data = {
'TOWNS': available_towns,
- 'form-TOTAL_FORMS': len(initial) + 3,
+ 'form-TOTAL_FORMS': len(initial) + PARCEL_FORMSET_EXTRA_FORM,
'form-INITIAL_FORMS': 0,
'form-MIN_NUM_FORMS': 0,
'form-MAX_NUM_FORMS': 100,