diff options
| -rw-r--r-- | ishtar_common/models_imports.py | 9 | ||||
| -rw-r--r-- | ishtar_common/views.py | 4 | 
2 files changed, 12 insertions, 1 deletions
| diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 4a5654781..0a6a52c73 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -148,17 +148,24 @@ class ImporterType(models.Model):          DEFAULTS = dict([(default.keys, default.values)                           for default in self.defaults.all()])          LINE_FORMAT = [] +        LINE_EXPORT_FORMAT = []          idx = 0          for column in self.columns.order_by('col_number').all():              idx += 1              while column.col_number > idx:                  LINE_FORMAT.append(None) +                LINE_EXPORT_FORMAT.append(None)                  idx += 1              targets = []              formater_types = []              nb = column.targets.count()              if not nb:                  LINE_FORMAT.append(None) +                if column.export_field_name: +                    LINE_EXPORT_FORMAT.append( +                        ImportFormater(column.export_field_name, +                                        label=column.label) +                    )                  continue              force_news = []              concat_str = [] @@ -189,6 +196,7 @@ class ImporterType(models.Model):              formater = ImportFormater(targets, formater_types,                                        **formater_kwargs)              LINE_FORMAT.append(formater) +            LINE_EXPORT_FORMAT.append(formater)          UNICITY_KEYS = []          if self.unicity_keys:              UNICITY_KEYS = [un.strip() for un in self.unicity_keys.split(';')] @@ -198,6 +206,7 @@ class ImporterType(models.Model):          args = {'OBJECT_CLS': OBJECT_CLS, 'DESC': self.description,                  'DEFAULTS': DEFAULTS, 'LINE_FORMAT': LINE_FORMAT,                  'UNICITY_KEYS': UNICITY_KEYS, +                'LINE_EXPORT_FORMAT': LINE_EXPORT_FORMAT,                  'MODEL_CREATION_LIMIT': MODEL_CREATION_LIMIT}          name = str(''.join(              x for x in slugify(self.name).replace('-', ' ').title() diff --git a/ishtar_common/views.py b/ishtar_common/views.py index bd558a62e..2ea10d0e8 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -1284,8 +1284,10 @@ def get_by_importer(request, slug, data_type='json', full=False,          return HttpResponse(res, content_type='text/plain')      imp = q.all()[0].get_importer_class()      cols, col_names = [], [] -    for formater in imp.LINE_FORMAT: +    for formater in imp.LINE_EXPORT_FORMAT:          if not formater: +            cols.append('') +            col_names.append("")              continue          cols.append(formater.export_field_name)          col_names.append(formater.label) | 
