diff options
Diffstat (limited to 'archaeological_operations/wizards.py')
| -rw-r--r-- | archaeological_operations/wizards.py | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index 081281d8a..707f4f96f 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -85,6 +85,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: @@ -108,6 +112,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() @@ -118,10 +123,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]) | 
