From f7c7e8227bf94ef7d900b49e13137a35d9d33477 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 27 Nov 2015 13:05:30 +0100 Subject: Wizards: fix many to many save when same object add multiple times --- ishtar_common/wizards.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ishtar_common/wizards.py') 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) -- cgit v1.2.3