diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-02-07 11:29:57 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:21:00 +0100 |
commit | 641830616108b3f6e7210600a3b0a0f9f1a227a9 (patch) | |
tree | f4b6674a743ce1b66dc93284f1521a7fcae8fa68 /archaeological_operations/views.py | |
parent | 1ddb738376757581fc8ae4bb8207656953176a92 (diff) | |
download | Ishtar-641830616108b3f6e7210600a3b0a0f9f1a227a9.tar.bz2 Ishtar-641830616108b3f6e7210600a3b0a0f9f1a227a9.zip |
Operation - Parcels - Modify: fix parcel deletion
Diffstat (limited to 'archaeological_operations/views.py')
-rw-r--r-- | archaeological_operations/views.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 016a43560..f5d1c514f 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -452,7 +452,9 @@ def operation_modify_parcels(request, pk): post_data = formset.cleaned_data for data in post_data: - print(data) + if (not data.get('parcel_number') or not data.get('section')) and \ + not data.get('public_domain'): + continue current_parcel = None if data.get("pk"): try: @@ -464,8 +466,8 @@ def operation_modify_parcels(request, pk): not_deleted_or_associated = True for key, value in data.items(): - if key == "DELETE" and value == True: - parcel_associated_by_context_record = models.ContextRecord.objects.filter(parcel=current_parcel.pk).all() + if key == "DELETE" and value is True: + parcel_associated_by_context_record = ContextRecord.objects.filter(parcel=current_parcel.pk).all() if parcel_associated_by_context_record.count() > 0: raise ValidationError("This parcel is associated with a context record. It can't be deleted.") else: @@ -486,7 +488,10 @@ def operation_modify_parcels(request, pk): town = models.Town.objects.get(pk=int(data.get("town"))) ) operation.parcels.add(parcel_to_add) + return redirect(reverse("operation-parcels-modify", args=[pk])) else: + print(formset.errors) + print(formset.non_form_errors()) print("je passe ici") else: formset = formset_class(initial=initial, data=data) |