summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_finds/models.py8
-rw-r--r--ishtar_common/data_importer.py5
2 files changed, 10 insertions, 3 deletions
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index 479880887..80b2b9074 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -110,6 +110,7 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
index = models.IntegerField(u"Index", default=0)
material_index = models.IntegerField(u"Material index", default=0)
history = HistoricalRecords()
+ RELATED_POST_PROCESS = ['find']
class Meta:
verbose_name = _(u"Base find")
@@ -152,7 +153,6 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
# OPE|FIND_index
if not self.context_record.operation:
return
- self.get_last_find()
ope = self.context_record.operation
c_id = [unicode(ope.code_patriarche) or
(unicode(ope.year) + "-" + unicode(ope.operation_code))]
@@ -472,7 +472,10 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
idx = BaseFind.objects\
.filter(context_record=base_find.context_record)\
.aggregate(Max('index'))
- base_find.index = idx and idx['index__max'] + 1 or 1
+ base_find.index = 1
+ if idx and idx['index__max']:
+ base_find.index = idx['index__max'] + 1
+ base_find.save()
# if not base_find.material_index:
# idx = BaseFind.objects\
# .filter(context_record=base_find.context_record,
@@ -480,7 +483,6 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
# .aggregate(Max('material_index'))
# base_find.material_index = \
# idx and idx['material_index__max'] + 1 or 1
- base_find.save()
class FindSource(Source):
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py
index 1251aaf4c..1614cfa1f 100644
--- a/ishtar_common/data_importer.py
+++ b/ishtar_common/data_importer.py
@@ -755,7 +755,12 @@ class Importer(object):
is_superuser=True).order_by('pk')[0]
def post_processing(self, item, data):
+ # force django based post-processing for the item
item.save()
+ if hasattr(item, 'RELATED_POST_PROCESS'):
+ for related_key in item.RELATED_POST_PROCESS:
+ for related in getattr(item, related_key).all():
+ related.save()
return item
def initialize(self, table, output='silent', choose_default=False):