diff options
Diffstat (limited to 'archaeological_operations')
| -rw-r--r-- | archaeological_operations/tests.py | 15 | ||||
| -rw-r--r-- | archaeological_operations/views.py | 5 | 
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, | 
