diff options
| -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)  | 
