diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-11-17 22:40:37 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-11-17 22:40:37 +0100 |
commit | c085fb4744d04ea7956a62b9151f62a8008da1d2 (patch) | |
tree | 3bee2579aad46b25cae3736801d71d2326834d6f | |
parent | ac268adb38f984041bfab70027a563b5d4c68ad2 (diff) | |
download | Ishtar-c085fb4744d04ea7956a62b9151f62a8008da1d2.tar.bz2 Ishtar-c085fb4744d04ea7956a62b9151f62a8008da1d2.zip |
Imports: force re-save on some related models
-rw-r--r-- | archaeological_finds/models.py | 8 | ||||
-rw-r--r-- | ishtar_common/data_importer.py | 5 |
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): |