From 049fdf160fbe176c5ea753499b9e7885b3ebf302 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 15 May 2019 12:18:56 +0200 Subject: Data importer: manage concat of M2M (many columns) --- ishtar_common/data_importer.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'ishtar_common/data_importer.py') diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 95763ae09..c568f1861 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -36,7 +36,7 @@ from django.db.models import Q from django.template.defaultfilters import slugify from django.utils.translation import ugettext_lazy as _ -from ishtar_common.utils import get_all_field_names, update_data +from ishtar_common.utils import debug_line_no, get_all_field_names, update_data NEW_LINE_BREAK = '#####@@@#####' @@ -1015,13 +1015,21 @@ class Importer(object): for idx, key in enumerate(keys): if idx == (len(keys) - 1): # last if concat: - if key not in current_data: - current_data[key] = "" - if not value: - continue - current_data[key] = (current_data[key] + concat_str) \ - if current_data[key] else u"" - current_data[key] += value + if isinstance(value, (list, tuple)): + if key not in current_data: + current_data[key] = [] + if not value: + continue + current_data[key] += value + else: + if key not in current_data: + current_data[key] = "" + if not value: + continue + current_data[key] = ( + current_data[key] + concat_str) \ + if current_data[key] else u"" + current_data[key] += value elif force_value and value: if concat_str and key in current_data \ and current_data[key]: -- cgit v1.2.3