diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-02-04 13:46:50 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-02-04 13:46:50 +0100 |
commit | b7b200e4ba1c54d83bbda5c47c9e96ddb36bbc0d (patch) | |
tree | 6a0f36c3476574e7eb80ce08f9a1a513b2b31da3 /ishtar_common | |
parent | 9c23bf1d9a7b50552dace564332f18ecf8ec1653 (diff) | |
download | Ishtar-b7b200e4ba1c54d83bbda5c47c9e96ddb36bbc0d.tar.bz2 Ishtar-b7b200e4ba1c54d83bbda5c47c9e96ddb36bbc0d.zip |
Imports: adapt auto model creation for importers to new importer model
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/data_importer.py | 5 | ||||
-rw-r--r-- | ishtar_common/models.py | 2 | ||||
-rw-r--r-- | ishtar_common/tests.py | 4 |
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', |