summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar_common/data_importer.py5
-rw-r--r--ishtar_common/models.py2
-rw-r--r--ishtar_common/tests.py4
3 files changed, 8 insertions, 3 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py
index 49705f0df..de4883c69 100644
--- a/ishtar_common/data_importer.py
+++ b/ishtar_common/data_importer.py
@@ -640,6 +640,9 @@ class Importer(object):
model_name = self.OBJECT_CLS.__module__ + '.' + \
self.OBJECT_CLS.__name__
+ model_cls, c = models.ImporterModel.object.get_or_create(
+ klass=model_name, default={'name': self.OBJECT_CLS.__name__}
+ )
unicity_keys = ''
if self.UNICITY_KEYS:
@@ -647,7 +650,7 @@ class Importer(object):
importer = models.ImporterType.objects.create(
slug=self.SLUG, name=name, description=self.DESC,
- associated_models=model_name, unicity_keys=unicity_keys)
+ associated_models=model_cls, unicity_keys=unicity_keys)
for default in self.DEFAULTS:
values = self.DEFAULTS[default]
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 7b596d209..6e655776d 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1756,7 +1756,7 @@ class ImporterType(models.Model):
blank=True, null=True)
associated_models = models.ForeignKey(
ImporterModel, verbose_name=_(u"Associated model"),
- related_name='+', blank=True, null=True)
+ related_name='+', blank=True, null=True)
created_models = models.ManyToManyField(
ImporterModel, verbose_name=_(u"Models that can accept new items"),
blank=True, null=True, help_text=_(u"Leave blank for no restrictions"),
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index b57ff0a94..a2d7bf46c 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -771,8 +771,10 @@ class ImportTest(TestCase):
# create an import, fields are not relevant...
create_user()
+ imp_model = models.ImporterModel.objects.create(
+ klass='ishtar_common.models.Person', name='Person')
importer_type = models.ImporterType.objects.create(
- associated_models='ishtar_common.models.Person')
+ associated_models=imp_model)
mcc_operation_file = DjangoFile(file(
settings.ROOT_PATH +
'../archaeological_operations/tests/MCC-operations-example.csv',