summaryrefslogtreecommitdiff
path: root/ishtar_common/wizards.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-11-27 13:05:30 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-11-27 13:05:30 +0100
commit0fc27869f44cdb5af8f34e097e970218cefdf49a (patch)
treefd140c4b2f0b4a119f8b09aef27f5efc8eda8de8 /ishtar_common/wizards.py
parentdd83004867c24bb7521024df8c0660370606680f (diff)
downloadIshtar-0fc27869f44cdb5af8f34e097e970218cefdf49a.tar.bz2
Ishtar-0fc27869f44cdb5af8f34e097e970218cefdf49a.zip
Wizards: fix many to many save when same object add multiple times
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r--ishtar_common/wizards.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 180ed4618..5f3d440e4 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -477,10 +477,12 @@ class Wizard(NamedUrlWizardView):
value['history_modifier'] = self.request.user
value = model.objects.create(**value)
value.save()
- getattr(obj, key + 's').add(value)
- # necessary to manage interaction between models like
- # material_index management for baseitems
- obj.save()
+ # check that an item is not add multiple times (forged forms)
+ if value not in getattr(obj, key + 's').all():
+ getattr(obj, key + 's').add(value)
+ # necessary to manage interaction between models like
+ # material_index management for baseitems
+ obj.save()
dct = {'item': obj}
# force evaluation of lazy urls
wizard_done_window = unicode(self.wizard_done_window)