summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/wizards.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index 01e717b18..9e6b9d03a 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -88,6 +88,10 @@ class OperationWizard(Wizard):
elif step.startswith('parcels-') and self.get_current_file():
# if a file is acciated to the operation add the button "Add all"
context['add_all'] = True
+ if step.startswith('parcels') and\
+ hasattr(self, 'automatic_parcel_association'):
+ context['automatic_parcel_association'] = \
+ self.automatic_parcel_association
# reminder of the current file
reminder = self.get_reminder()
if reminder:
@@ -111,6 +115,7 @@ class OperationWizard(Wizard):
return sorted(towns, key=lambda x:x[1])
def get_available_parcels(self, file):
+ self.automatic_parcel_association = False
parcels = []
current_parcels = []
operation = self.get_current_object()
@@ -121,10 +126,14 @@ class OperationWizard(Wizard):
parcels.append((parcel.pk, parcel.short_label))
try:
for parcel in file.parcels.all():
- if (parcel.town, parcel.section, parcel.parcel_number) \
- in current_parcels:
+ key = (parcel.town, parcel.section, parcel.parcel_number)
+ if key in current_parcels:
+ current_parcels.pop(current_parcels.index(key))
continue
parcels.append((parcel.pk, parcel.short_label))
+ if current_parcels:
+ # not all operation parcel exist for the file
+ self.automatic_parcel_association = True
except (ValueError, ObjectDoesNotExist):
pass
return sorted(parcels, key=lambda x:x[1])