diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-09 23:08:51 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-09 23:08:51 +0100 | 
| commit | c2d86b659a9ad00b1e2cb0485e1310504c8fd03c (patch) | |
| tree | d95d1ca9e9971b465f235cbb86091cd2cf3c7325 /ishtar_common/models.py | |
| parent | 1c381564ea9ed133f73e0b330468b204e7a034f1 (diff) | |
| parent | 53f0a5c95c34c0db67528422583dc3e90f20f705 (diff) | |
| download | Ishtar-c2d86b659a9ad00b1e2cb0485e1310504c8fd03c.tar.bz2 Ishtar-c2d86b659a9ad00b1e2cb0485e1310504c8fd03c.zip | |
Merge branch 'master' into v0.9
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 | 
