summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 09ce9aba5..981ea74f2 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1095,14 +1095,14 @@ MODELS = [
_(u"Operation source")),
]
-IMPORTER_CLASSES = []
+IMPORTER_CLASSES = {}
if 'archaeological_files' in settings.INSTALLED_APPS:
MODELS = [('archaeological_files.models.File', _(u"Archaeological files"))]\
+ MODELS
- IMPORTER_CLASSES = [
- 'archaeological_files.data_importer.FileImporterSraPdL'] + \
- IMPORTER_CLASSES
+ IMPORTER_CLASSES.update({
+ 'sra-pdl-files':
+ 'archaeological_files.data_importer.FileImporterSraPdL'})
if 'archaeological_context_records' in settings.INSTALLED_APPS:
MODELS = [('archaeological_context_records.models.ContextRecord',
_(u"Context records")), ] + MODELS
@@ -1345,21 +1345,32 @@ class ImportTarget(models.Model):
formater_type = models.ForeignKey("FormaterType")
force_new = models.BooleanField(_(u"Force creation of new item"),
default=False)
+ comment = models.TextField(_(u"Comment"), blank=True, null=True)
class Meta:
verbose_name = _(u"Importer - Target")
verbose_name_plural = _(u"Importer - Targets")
def __unicode__(self):
- return self.target[:50]
+ return self.target[:50] if self.target else self.comment
@property
def associated_model(self):
- return get_associated_model(
- self.column.importer_type.associated_models,
- self.target.split('__'))
+ try:
+ return get_associated_model(
+ self.column.importer_type.associated_models,
+ self.target.split('__'))
+ except KeyError:
+ return
def get_choices(self):
+ if self.formater_type.formater_type == 'UnknowType' \
+ and self.column.importer_type.slug:
+ cls = self.column.importer_type.get_importer_class()
+ formt = cls().line_format[self.column.col_number - 1]
+ if hasattr(formt.formater, 'choices'):
+ return formt.formater.choices
+ return []
if self.formater_type.formater_type == 'StrToBoolean':
return [('', '--' * 8),
('True', _(u"True")),