summaryrefslogtreecommitdiff
path: root/ishtar_common/models_imports.py
diff options
context:
space:
mode:
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
commit01d0e97cabb6fcae133eaeabb7db24309a800e36 (patch)
tree8d49b4b68eae56067826c2a96b30f8a2dfca86e5 /ishtar_common/models_imports.py
parente1b60b6f459dbbb4d87ccab6d25902dbfe876868 (diff)
downloadIshtar-01d0e97cabb6fcae133eaeabb7db24309a800e36.tar.bz2
Ishtar-01d0e97cabb6fcae133eaeabb7db24309a800e36.zip
Import/export: manage export only columns
Diffstat (limited to 'ishtar_common/models_imports.py')
-rw-r--r--ishtar_common/models_imports.py9
1 files changed, 9 insertions, 0 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()