summaryrefslogtreecommitdiff
path: root/archaeological_operations/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/views.py')
-rw-r--r--archaeological_operations/views.py11
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)