summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-19 20:27:29 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-19 20:27:29 +0100
commit56d15235cf3a4867a1887f6d6d82798874c4e2e1 (patch)
tree12cc21aabef7ec8312d27ddeb31b1fa7f3c62b16 /ishtar_common
parente2fdfc4929223099e85c1228b3671beb5a62fec9 (diff)
downloadIshtar-56d15235cf3a4867a1887f6d6d82798874c4e2e1.tar.bz2
Ishtar-56d15235cf3a4867a1887f6d6d82798874c4e2e1.zip
Find form: fix period saving.
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/tests.py12
-rw-r--r--ishtar_common/wizards.py6
2 files changed, 14 insertions, 4 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 77247d6a0..f22e42e38 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -176,15 +176,21 @@ class WizardTest(object):
}
if current_step in form_data:
d = form_data[current_step]
- for k in d:
- data['{}-{}'.format(current_step, k)] = d[k]
+ if type(d) in (list, tuple): # formset
+ for d_idx, item in enumerate(d):
+ for k in item:
+ data['{}-{}-{}'.format(
+ current_step, d_idx, k)] = item[k]
+ else:
+ for k in d:
+ data['{}-{}'.format(current_step, k)] = d[k]
next_idx, next_form = idx + 1, None
while len(self.steps) > next_idx:
if self.steps[idx + 1][0] not in ignored:
next_form = self.steps[idx + 1][0]
break
- next_idx = next_idx + 1
+ next_idx += 1
if next_form:
try:
response = self.client.post(url, data)
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 87a126879..18336cff5 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -634,7 +634,11 @@ class Wizard(NamedUrlWizardView):
if type(value) == dict:
model = related_model.model
if hasattr(related_model, 'through') and \
- related_model.through:
+ related_model.through and \
+ hasattr(related_model.through, 'RELATIVE_MODELS') \
+ and self.get_saved_model() in \
+ related_model.through.RELATIVE_MODELS:
+ # the form is dealing with the through parameter
model = related_model.through
# not m2m -> foreign key
if not hasattr(related_model, 'clear'):