diff options
Diffstat (limited to 'ishtar_common/data_importer.py')
-rw-r--r-- | ishtar_common/data_importer.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 2ab5ba28f..ebf85f816 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2013-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2013-2017 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -343,7 +343,7 @@ class StrChoiceFormater(Formater, ChoiceChecker): if hasattr(value, 'pk'): value = value.pk q['value'] = value - with transaction.commit_on_success(): + with transaction.atomic(): try: t, created = TargetKey.objects.get_or_create(**q) except IntegrityError: @@ -405,7 +405,7 @@ class StrChoiceFormater(Formater, ChoiceChecker): target.is_set = True target.save() else: - with transaction.commit_on_success(): + with transaction.atomic(): q['value'] = self.equiv_dict[value] q['is_set'] = True try: @@ -419,7 +419,7 @@ class StrChoiceFormater(Formater, ChoiceChecker): 'associated_import': import_instance} if TargetKey.objects.filter(**q).count(): continue - with transaction.commit_on_success(): + with transaction.atomic(): try: TargetKey.objects.create(**q) except IntegrityError: @@ -812,7 +812,7 @@ class Importer(object): self.output = output if not self.history_modifier: if self.import_instance: - self.history_modifier = self.import_instance.user + self.history_modifier = self.import_instance.user.user_ptr else: # import made by the CLI: get the first admin self.history_modifier = User.objects.filter( @@ -1341,6 +1341,7 @@ class Importer(object): # attr_class is a FileField attribute if hasattr(field, 'attr_class') and k in v: extra_fields[k] = v.pop(k) + created = False if not self.MODEL_CREATION_LIMIT or \ model in self.MODEL_CREATION_LIMIT: v, created = model.objects.get_or_create( |