diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 24704dd21..a2341abdc 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1738,7 +1738,8 @@ def import_class(full_path_classname): mods = full_path_classname.split('.') if len(mods) == 1: mods = ['ishtar_common', 'models', mods[0]] - elif 'models' not in mods: + elif 'models' not in mods and 'models_finds' not in mods \ + and 'models_treatments' not in mods: raise SuspiciousOperation( u"Try to import a non model from a string") module = import_module('.'.join(mods[:-1])) @@ -1829,8 +1830,12 @@ class ImporterType(models.Model): (field.field_name, field.force_new, field.concat, field.concat_str) for field in column.duplicate_fields.all()] + formater_kwargs['label'] = column.label formater_kwargs['required'] = column.required formater_kwargs['force_new'] = force_news + if column.export_field_name: + formater_kwargs['export_field_name'] = [ + column.export_field_name] formater = ImportFormater(targets, formater_types, **formater_kwargs) LINE_FORMAT.append(formater) @@ -1952,6 +1957,11 @@ class ImporterColumn(models.Model): description = models.TextField(_("Description"), blank=True, null=True) regexp_pre_filter = models.ForeignKey("Regexp", blank=True, null=True) required = models.BooleanField(_(u"Required"), default=False) + export_field_name = models.CharField( + _(u"Export field name"), blank=True, null=True, max_length=200, + help_text=_(u"Fill this field if the field name is ambiguous for " + u"export. For instance: concatenated fields.") + ) class Meta: verbose_name = _(u"Importer - Column") @@ -2748,11 +2758,10 @@ class Person(Address, Merge, OwnPerms, ValueGetter): def save(self, *args, **kwargs): super(Person, self).save(*args, **kwargs) - if not self.raw_name: - self.raw_name = get_external_id( - 'person_raw_name', self) - if self.raw_name: - self.save() + raw_name = get_external_id('person_raw_name', self) + if raw_name and self.raw_name != raw_name: + self.raw_name = raw_name + self.save() if hasattr(self, 'responsible_town_planning_service'): for fle in self.responsible_town_planning_service.all(): fle.save() # force update of raw_town_planning_service |