summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-04-10 16:34:33 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:20 +0100
commit3176e8cecfbf8e0e4dbcff9d5f8c19f164198010 (patch)
tree1a7567e73ab784209a74ede0481bfc2e21079748
parent17b74b59e0a1def477be303340fd456c6e5e5c73 (diff)
downloadIshtar-3176e8cecfbf8e0e4dbcff9d5f8c19f164198010.tar.bz2
Ishtar-3176e8cecfbf8e0e4dbcff9d5f8c19f164198010.zip
Fix merge candidate for containers
-rw-r--r--archaeological_warehouse/models.py6
-rw-r--r--archaeological_warehouse/templates/ishtar/wizard/wizard_container.html (renamed from archaeological_warehouse/templates/ishtar/wizard/wizard_containerlocalisation.html)0
-rw-r--r--ishtar_common/models.py4
3 files changed, 9 insertions, 1 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index 53e50976d..8d2a3fb71 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -482,6 +482,7 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,
SearchVectorConfig("division__reference"),
SearchVectorConfig("division__division__division__label"),
]
+ PARENT_SEARCH_VECTORS = ["parent"]
# search parameters
EXTRA_REQUEST_KEYS = {
@@ -704,6 +705,7 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,
verbose_name=_("Main image"), blank=True, null=True)
DISABLE_POLYGONS = False
+ MERGE_ATTRIBUTE = "get_cached_division"
class Meta:
verbose_name = _("Container")
@@ -751,6 +753,10 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,
cached_label = " - ".join(items)
return cached_label
+ @property
+ def get_cached_division(self):
+ return self._generate_cached_division()
+
def _generate_cached_division(self):
parents = []
parent = self.parent
diff --git a/archaeological_warehouse/templates/ishtar/wizard/wizard_containerlocalisation.html b/archaeological_warehouse/templates/ishtar/wizard/wizard_container.html
index 4d0a63c17..4d0a63c17 100644
--- a/archaeological_warehouse/templates/ishtar/wizard/wizard_containerlocalisation.html
+++ b/archaeological_warehouse/templates/ishtar/wizard/wizard_container.html
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 071b05598..9011c4638 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -4228,6 +4228,7 @@ class Merge(models.Model):
# 1 for one word similarity, 2 for two word similarity, etc.
MERGE_CLEMENCY = None
EMPTY_MERGE_KEY = '--'
+ MERGE_ATTRIBUTE = "name"
class Meta:
abstract = True
@@ -4235,7 +4236,8 @@ class Merge(models.Model):
def generate_merge_key(self):
if self.archived:
return
- self.merge_key = slugify(self.name if self.name else '')
+ merge_attr = getattr(self, self.MERGE_ATTRIBUTE)
+ self.merge_key = slugify(merge_attr if merge_attr else '')
if not self.merge_key:
self.merge_key = self.EMPTY_MERGE_KEY
self.merge_key = self.merge_key