diff options
author | Cefin <kevon@tuta.io> | 2022-01-27 13:52:53 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:20:59 +0100 |
commit | 0f3baa049c81e336457d529542e439b0d6c4827d (patch) | |
tree | f92068da9e5fed6af5ad76cbd74ae1a1020f8109 /archaeological_operations | |
parent | 85c707ffa667bfa90b66d32c4399dcdce5d90b8a (diff) | |
download | Ishtar-0f3baa049c81e336457d529542e439b0d6c4827d.tar.bz2 Ishtar-0f3baa049c81e336457d529542e439b0d6c4827d.zip |
Operation - Parcels - Modify: beginning draft version of post tests #5227
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/tests.py | 19 | ||||
-rw-r--r-- | archaeological_operations/views.py | 22 |
2 files changed, 27 insertions, 14 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 84b684410..c2be8c050 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -1679,6 +1679,25 @@ class ParcelTest(ImportTest, TestCase): self.assertContains(response, parcel_1.parcel_number) self.assertContains(response, parcel_2.parcel_number) + data = { + "form-0-year": 2021, + "form-0-section": "SCT1", + "form-0-parcel_number": "001", + "form-0-town": town_2, + "form-1-year": 2021, + "form-1-section": "SCT1", + "form-1-parcel_number": "002", + "form-1-town": town_2, + } + post_response = c.post(reverse("operation-parcels-modify", data)) + + self.assertEqual(post_response.status_code, 200) + self.assertContains(post_response, town_2.name) + self.assertContains(post_response, 2021) + self.assertContains(post_response, "SCT1") + self.assertContains(post_response, "001") + self.assertContains(post_response, "002") + def create_orga(user): orga_type, created = OrganizationType.objects.get_or_create(txt_idx="operator") diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index c0f3ab56c..dc03f0641 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -451,11 +451,7 @@ def operation_modify_parcels(request, pk): town = post_data.get("town") ) operation.parcels.add(parcel_to_add) - - # request.POST = post_data - # formset_class(request.POST).save() else: - print(formset.non_form_errors()) print("je passe ici") formset = formset_class() else: @@ -463,21 +459,19 @@ def operation_modify_parcels(request, pk): if parcels: for parcel in parcels: town = models.Town.objects.get(pk=parcel.town_id) - initial.append({ - "pk": parcel.pk, - "town": town, - "year": parcel.year, - "section": parcel.section, - "parcel_number": parcel.parcel_number, - "public_domain": parcel.public_domain - }) + initial.append({ + "pk": parcel.pk, + "town": town, + "year": parcel.year, + "section": parcel.section, + "parcel_number": parcel.parcel_number, + "public_domain": parcel.public_domain + }) data = { 'TOWNS': available_towns, 'form-TOTAL_FORMS': len(initial), 'form-INITIAL_FORMS': 0, - 'form-MIN_NUM_FORMS': 0, - 'form-MAX_NUM_FORMS': 100, } formset = formset_class(initial=initial, data=data) |