summaryrefslogtreecommitdiff
path: root/archaeological_operations/wizards.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/wizards.py')
-rw-r--r--archaeological_operations/wizards.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index 1e4de70b7..7fdc26b12 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -39,6 +39,9 @@ class OperationWizard(Wizard):
model = models.Operation
object_parcel_type = 'operation'
parcel_step_key = 'parcelsgeneral-'
+ town_step_key = 'towns-' # step contening the current(s) town(s)
+ 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 +50,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 +133,18 @@ 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_form_key = self.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 not self.multi_towns and town_ids:
+ town_ids = [town_ids]
towns = []
for town_id in town_ids:
try: