diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-05-19 19:03:50 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-05-19 19:03:50 +0200 |
commit | ea424eb36b3adef831683ec354b3dbd7d6b853f9 (patch) | |
tree | 31b6978a694d5233fe100fcc4390b8a4666972b9 /ishtar_common/models.py | |
parent | 927115ea5e23f30996b8f4f67ba13bf4f92dfb95 (diff) | |
parent | bdb50e2e41e863ddf59676e0ce8b06cfaf96c237 (diff) | |
download | Ishtar-ea424eb36b3adef831683ec354b3dbd7d6b853f9.tar.bz2 Ishtar-ea424eb36b3adef831683ec354b3dbd7d6b853f9.zip |
Merge branch 'stable'
Conflicts:
ishtar_common/data_importer.py
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 89e56a312..2174b1edb 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -988,6 +988,10 @@ MODELS = [ if 'archaeological_files' in settings.INSTALLED_APPS: MODELS = [('archaeological_files.models.File', _(u"Archaeological files")), ] + MODELS +if 'archaeological_context_records' in settings.INSTALLED_APPS: + MODELS = [('archaeological_context_records.models.ContextRecord', + _(u"Archaeological files")), + ] + MODELS def get_model_fields(model): """ @@ -1068,15 +1072,21 @@ class ImporterType(models.Model): return newclass def get_associated_model(parent_model, keys): - field = None - OBJECT_CLS = import_class(parent_model) + model = None + OBJECT_CLS = None + if isinstance(parent_model, unicode) or \ + isinstance(parent_model, str): + OBJECT_CLS = import_class(parent_model) + else: + OBJECT_CLS = parent_model for idx, item in enumerate(keys): if not idx: field = get_model_fields(OBJECT_CLS)[item] + if hasattr(field, 'rel') and hasattr(field.rel, 'to'): + model = field.rel.to else: - raise NotImplemented() - if hasattr(field, 'rel') and hasattr(field.rel, 'to'): - return field.rel.to + return get_associated_model(model, keys[1:]) + return model class ImporterDefault(models.Model): """ @@ -1240,6 +1250,7 @@ class TargetKey(models.Model): if v: v.add_key(self.key) return obj + TARGET_MODELS = [ ('OrganizationType', _(u"Organization type")), ('SourceType', _(u"Source type")), |