diff options
Diffstat (limited to 'archaeological_operations/wizards.py')
| -rw-r--r-- | archaeological_operations/wizards.py | 25 | 
1 files changed, 17 insertions, 8 deletions
| diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index 1e4de70b7..59eb1d554 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -39,6 +39,10 @@ class OperationWizard(Wizard):      model = models.Operation      object_parcel_type = 'operation'      parcel_step_key = 'parcelsgeneral-' +    # step contening the current(s) town(s) +    town_step_keys = ['towns-', 'townsgeneral-'] +    town_input_id = 'town' # input id of the current(s) town(s) +    multi_towns = True # true if current town are multi      wizard_done_window = reverse_lazy('show-operation')      def get_template_names(self): @@ -47,8 +51,7 @@ class OperationWizard(Wizard):          if current_step.startswith('towns-'):              #templates = ['ishtar/wizard/towns_wizard.html'] + templates              pass -        if current_step.startswith('parcels-') or \ -           current_step.startswith('parcelsgeneral-') : +        if current_step.startswith(self.parcel_step_key):              templates = ['ishtar/wizard/parcels_wizard.html'] + templates          return templates @@ -131,16 +134,22 @@ class OperationWizard(Wizard):          # manage the dynamic choice of towns          if step.startswith('towns') and hasattr(form, 'management_form'):              data['TOWNS'] = self.get_towns() -        elif step.startswith('parcels') and hasattr(form, 'management_form'): +        elif step.startswith(self.parcel_step_key) \ +             and hasattr(form, 'management_form'):              file = self.get_current_file()              if file:                  data['PARCELS'] = self.get_available_parcels(file)              else: -                town_form_key = step.startswith('parcelsgeneral') \ -                                and 'townsgeneral-' or 'towns-' -                town_form_key += self.url_name -                town_ids = self.session_get_value(town_form_key, 'town', -                                                  multi=True) or [] +                town_ids = [] +                for town_step_key in self.town_step_keys: +                    town_form_key = town_step_key + self.url_name +                    town_ids = self.session_get_value(town_form_key, +                                                  self.town_input_id, +                                                  multi=self.multi_towns) or [] +                    if town_ids: +                        break +                if not self.multi_towns and town_ids: +                    town_ids = [town_ids]                  towns = []                  for town_id in town_ids:                      try: | 
