summaryrefslogtreecommitdiff
path: root/ishtar_common/models_common.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-11-18 16:46:37 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:21 +0100
commitb27fabdea6c6bfba75521dc84f5a321e61e6ef52 (patch)
tree2b4452bc7fec7de7a90e81d9055a8b9971b18c5c /ishtar_common/models_common.py
parent4fa501cb189c61d94a2ca53a604f3db7a212153c (diff)
downloadIshtar-b27fabdea6c6bfba75521dc84f5a321e61e6ef52.tar.bz2
Ishtar-b27fabdea6c6bfba75521dc84f5a321e61e6ef52.zip
Complex index generation with JINJA2 templates
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r--ishtar_common/models_common.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index 4abc81a76..4f82cde8f 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -5,16 +5,6 @@
Generic models and tools for models
"""
-"""
-from ishtar_common.models import GeneralType, get_external_id, \
- LightHistorizedItem, OwnPerms, Address, post_save_cache, \
- DashboardFormItem, document_attached_changed, SearchAltName, \
- DynamicRequest, GeoItem, QRCodeItem, SearchVectorConfig, DocumentItem, \
- QuickAction, MainItem, Merge
-
-
-"""
-
import copy
from collections import OrderedDict
import datetime
@@ -65,6 +55,16 @@ from ishtar_common.utils import get_cache, disable_for_loaddata, \
logger = logging.getLogger(__name__)
+"""
+from ishtar_common.models import GeneralType, get_external_id, \
+ LightHistorizedItem, OwnPerms, Address, post_save_cache, \
+ DashboardFormItem, document_attached_changed, SearchAltName, \
+ DynamicRequest, GeoItem, QRCodeItem, SearchVectorConfig, DocumentItem, \
+ QuickAction, MainItem, Merge
+
+
+"""
+
class CachedGen(object):
@classmethod
@@ -2364,6 +2364,8 @@ def document_attached_changed(sender, **kwargs):
return
for item in items:
+ for doc in item.documents.all():
+ doc.regenerate_all_ids()
q = item.documents.filter(
image__isnull=False).exclude(image='')
if item.main_image:
@@ -2727,8 +2729,8 @@ class CompleteIdentifierItem(models.Model, ImageContainerModel):
if not key or not key.strip():
return
keys = key.strip().split(";")
- if len(key) == 1 and hasattr(self, "get_index_" + key): # custom index
- # generation
+ if len(keys) == 1 and hasattr(self, "get_index_" + keys[0]):
+ # custom index generation
return getattr(self, "get_index_" + key)()
model = self.__class__
try:
@@ -2758,6 +2760,9 @@ class CompleteIdentifierItem(models.Model, ImageContainerModel):
def save(self, *args, **kwargs):
super(CompleteIdentifierItem, self).save(*args, **kwargs)
+ self.regenerate_all_ids()
+
+ def regenerate_all_ids(self):
if getattr(self, "_prevent_loop", False):
return
modified = False
@@ -2771,6 +2776,7 @@ class CompleteIdentifierItem(models.Model, ImageContainerModel):
self.complete_identifier = complete_id
if modified:
self._prevent_loop = True
+ self.skip_history_when_saving = True
self.save()