Commits

Anonymous committed a0325ea

Now it run a geolocalize task when a non geolocalized entity will be import

  • Participants
  • Parent commits 7f0bf2d

Comments (0)

Files changed (1)

src/macadjan_base/importer/converter_base.py

 
 from django.utils.translation import ugettext as _
 from macadjan_base import models
-        
+from macadjan_base.async_tasks import task__geolocalize_entity
+ 
 class EntityImporter:
     '''
     An object that can import entities from an archive and a converter.
                 self.process_exception(_(u'Error cerrando el archivo'), ex)
 
     def process_item(self, item):
-        slug = self.converter.get_slug_from_item(item)
+        slug = self.converter.get_slug_from_item()
         try:
             entity = models.Entity.objects.get(slug = slug)
         except models.Entity.DoesNotExist:
             entity = models.Entity()
         (entity, m2m) = self.converter.load_entity_from_item(entity, item)
         entity.save(update_dates = False)
+        if not entity.latirude or not entity.longitude:
+            task__geolocalize_entity.delay(entity.pk)    
         for subcategory in m2m['subcategories']:
             entity.subcategories.add(subcategory)
         self.imported_items.append(entity)