diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-10-06 10:47:56 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-10-24 12:06:09 +0200 |
commit | fcc1858d3e611c841d0aef8c970e2c1b56074b50 (patch) | |
tree | cbe3aade9f6d1fb7d97a678cf7d9526781fbdbc8 | |
parent | d13b19fb346b50b60f546c955f8ea8e9f552b726 (diff) | |
download | Ishtar-fcc1858d3e611c841d0aef8c970e2c1b56074b50.tar.bz2 Ishtar-fcc1858d3e611c841d0aef8c970e2c1b56074b50.zip |
Importer: do not crash on bad default configuration
-rw-r--r-- | ishtar_common/models_imports.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index b52219c11..d999f61d2 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -238,9 +238,18 @@ def get_associated_model(parent_model, keys): OBJECT_CLS = import_class(parent_model) else: OBJECT_CLS = parent_model + fields = get_model_fields(OBJECT_CLS) for idx, item in enumerate(keys): if not idx: - field = get_model_fields(OBJECT_CLS)[item] + if item not in fields: + raise ImporterError( + unicode( + _(u"Importer configuration error: " + u"\"{}\" is not available for \"{}\"." + u" Check your default and column " + u"configuration")).format( + item, OBJECT_CLS.__name__)) + field = fields[item] if hasattr(field, 'rel') and hasattr(field.rel, 'to'): model = field.rel.to if type(field) == ModelBase: |