summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-10-29 16:28:38 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-10-29 16:28:38 +0100
commit44bd95f480524b07222b9ca56cbb8d15061b806e (patch)
treee63894b647bc7b6d5af9f48596b8c2d7bbedac77 /archaeological_operations
parentdc7cea501d109bee8cdd3d5e9a0e47e8540fed9b (diff)
downloadIshtar-44bd95f480524b07222b9ca56cbb8d15061b806e.tar.bz2
Ishtar-44bd95f480524b07222b9ca56cbb8d15061b806e.zip
Archaeological files: fix parcel form
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/wizards.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index 93787fca2..cbc5a20c5 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -39,11 +39,12 @@ if FILES_AVAILABLE:
class OperationWizard(Wizard):
model = models.Operation
object_parcel_type = 'operation'
- parcel_step_key = 'parcelsgeneral-'
+ parcel_step_key = 'parcels'
# 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
+ multi_towns = False # true if current town are multi valued
+ towns_formset = True # true if towns are managed with formset
wizard_done_window = reverse_lazy('show-operation')
def get_template_names(self):
@@ -161,9 +162,11 @@ class OperationWizard(Wizard):
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 and type(town_ids) == unicode:
- town_ids = town_ids.split(',')
+ multi=self.towns_formset,
+ multi_value=self.multi_towns) or []
+ if town_ids:
+ if type(town_ids) == unicode:
+ town_ids = town_ids.split(',')
break
if type(town_ids) not in (list, tuple):
town_ids = [town_ids]
@@ -244,7 +247,8 @@ class OperationWizard(Wizard):
file = self.get_current_file()
if not file:
return super(OperationWizard, self).post(*args, **kwargs)
- parcel_form_key = "parcels-" + self.url_name
+ parcel_form_key = self.steps.current
+ # parcel_form_key = "parcels-" + self.url_name
idx = -1
# remove non relevant deleted keys
for k in post_data.keys():
@@ -253,7 +257,7 @@ class OperationWizard(Wizard):
for idx, parcel in enumerate(self.get_available_parcels(file)):
parcel_pk, parcel_name = parcel
post_data["%s-%d-parcel" % (parcel_form_key, idx)] = parcel_pk
- post_data[parcel_form_key + '-TOTAL_FORMS'] = idx + 1
+ post_data[parcel_form_key + '-TOTAL_FORMS'] = idx + 2
request.POST = post_data
return super(OperationWizard, self).post(*args, **kwargs)