diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-10-24 03:50:36 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-10-24 03:51:14 +0200 |
commit | 42116f233489b878a512295adb86b5556e7257f2 (patch) | |
tree | 9e64c8d168e0ed4e73e3725b9c06d072d62233ff /ishtar_common/models.py | |
parent | 5b5c1bd7dd865fb530b156212474846db59b2191 (diff) | |
download | Ishtar-42116f233489b878a512295adb86b5556e7257f2.tar.bz2 Ishtar-42116f233489b878a512295adb86b5556e7257f2.zip |
Imports: manage soft import (update) with unicity keys - script to initialize SRA file import
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 63ea7d2a8..fd0de385e 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1149,6 +1149,8 @@ class ImporterType(models.Model): associated_models = models.CharField(_(u"Associated model"), max_length=200, choices=MODELS) is_template = models.BooleanField(_(u"Is template"), default=False) + unicity_keys = models.CharField(_(u"Unicity keys (separator \";\")"), + blank=True, null=True, max_length=500) class Meta: verbose_name = _(u"Importer - Type") @@ -1197,8 +1199,12 @@ class ImporterType(models.Model): formater = ImportFormater(targets, formater_types, **formater_kwargs) LINE_FORMAT.append(formater) + UNICITY_KEYS = [] + if self.unicity_keys: + UNICITY_KEYS = [un.strip() for un in self.unicity_keys.split(';')] args = {'OBJECT_CLS': OBJECT_CLS, 'DESC': self.description, - 'DEFAULTS': DEFAULTS, 'LINE_FORMAT': LINE_FORMAT} + 'DEFAULTS': DEFAULTS, 'LINE_FORMAT': LINE_FORMAT, + 'UNICITY_KEYS': UNICITY_KEYS} name = str(''.join( x for x in slugify(self.name).replace('-', ' ').title() if not x.isspace())) @@ -1355,6 +1361,8 @@ class ImportTarget(models.Model): formater_type = models.ForeignKey("FormaterType") force_new = models.BooleanField(_(u"Force creation of new item"), default=False) + concat = models.BooleanField(_(u"Concatenate with existing"), + default=False) comment = models.TextField(_(u"Comment"), blank=True, null=True) class Meta: @@ -1604,6 +1612,9 @@ class Import(models.Model): blank=True, null=True) state = models.CharField(_(u"State"), max_length=2, choices=IMPORT_STATE, default='C') + conservative_import = models.BooleanField( + _(u"Conservative import"), default=False, + help_text='If set to true, do not overload existing values') creation_date = models.DateTimeField(_(u"Creation date"), auto_now_add=True, blank=True, null=True) @@ -1656,7 +1667,8 @@ class Import(models.Model): def get_importer_instance(self): return self.importer_type.get_importer_class()( - skip_lines=self.skip_lines, import_instance=self) + skip_lines=self.skip_lines, import_instance=self, + conservative_import=self.conservative_import) @property def data_table(self): |