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
commitf7c7e8227bf94ef7d900b49e13137a35d9d33477 (patch)
treefd140c4b2f0b4a119f8b09aef27f5efc8eda8de8 /ishtar_common/wizards.py
parent271873408f84e70a0639959d75305a05f17dc920 (diff)
downloadIshtar-f7c7e8227bf94ef7d900b49e13137a35d9d33477.tar.bz2
Ishtar-f7c7e8227bf94ef7d900b49e13137a35d9d33477.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)