diff options
Diffstat (limited to 'archaeological_operations/views.py')
| -rw-r--r-- | archaeological_operations/views.py | 22 | 
1 files changed, 22 insertions, 0 deletions
| diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index d0d33194f..0864bd1f9 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -27,6 +27,7 @@ from django.shortcuts import render, redirect  from django.urls import reverse  from django.views.generic import RedirectView  from ishtar_common.utils import ugettext_lazy as _, pgettext_lazy +from archaeological_operations.utils import parse_parcels  from django.forms import formset_factory  from archaeological_operations import models @@ -446,9 +447,29 @@ def operation_modify_parcels(request, pk):          new_data = {k: new_data[k][0] for k in new_data} # convert POST to classic dict          new_data.update(data)          formset = formset_class(new_data) +        parcel_selection = new_data.get('_parcel_selection', None) + +        if parcel_selection: +            selected_town = new_data.get("_town") +            _parcels = parse_parcels(parcel_selection) +            print("Parcel_Selection ", _parcels) +            print("Selected_Town ", selected_town) +            for p in _parcels: +                print(p) +                added_parcel = models.Parcel.objects.create( +                    year = int(p["year"]), +                    section = p["section"], +                    parcel_number = p["parcel_number"], +                    town = models.Town.objects.get(pk=int(selected_town)), +                    #  public_domain = parcel["public_domain"] +                ) +                operation.parcels.add(added_parcel) +            return redirect(reverse("operation-parcels-modify", args=[pk])) +          print(new_data)          if formset.is_valid():              for data in formset.cleaned_data: +                print("Data : ", data)                  if (not data.get('parcel_number') or not data.get('section')) and \                          not data.get('public_domain'):                      continue @@ -465,6 +486,7 @@ def operation_modify_parcels(request, pk):                      for key, value in data.items():                          if key == "DELETE" and value is True: +                            print("Je passe dans le delete")                              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.") | 
