diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-02-22 14:19:21 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-02-22 14:19:21 +0100 |
commit | 01d0e97cabb6fcae133eaeabb7db24309a800e36 (patch) | |
tree | 8d49b4b68eae56067826c2a96b30f8a2dfca86e5 | |
parent | e1b60b6f459dbbb4d87ccab6d25902dbfe876868 (diff) | |
download | Ishtar-01d0e97cabb6fcae133eaeabb7db24309a800e36.tar.bz2 Ishtar-01d0e97cabb6fcae133eaeabb7db24309a800e36.zip |
Import/export: manage export only columns
-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) |