summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-03-20 17:26:31 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-04-24 19:41:37 +0200
commit3920c6a34eaddee7397a93d08487194a5119e74f (patch)
tree4b6301374d3f3e57102e9ef267ba9643864fea53 /archaeological_finds
parentcffe0a8f34ebf72bebbb7c34ed994ada41c6f73c (diff)
downloadIshtar-3920c6a34eaddee7397a93d08487194a5119e74f.tar.bz2
Ishtar-3920c6a34eaddee7397a93d08487194a5119e74f.zip
Search: manage localized and non localized indexation
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models_finds.py37
-rw-r--r--archaeological_finds/models_treatments.py32
2 files changed, 53 insertions, 16 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index e93580418..f2897b02d 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -41,7 +41,7 @@ from ishtar_common.models import Document, GeneralType, \
ValueGetter, get_current_profile, IshtarSiteProfile, PRIVATE_FIELDS, \
GeoItem, BulkUpdatedItem, ExternalIdManager, QuickAction, \
MainItem, document_attached_changed, HistoryModel, DynamicRequest, \
- SearchAltName, QRCodeItem
+ SearchAltName, QRCodeItem, SearchVectorConfig
from archaeological_operations.models import AdministrativeAct, Operation
@@ -304,8 +304,14 @@ class BaseFind(BulkUpdatedItem, BaseHistorizedItem, GeoItem, OwnPerms):
RELATED_POST_PROCESS = ['find']
CACHED_LABELS = ['cache_short_id', 'cache_complete_id']
PARENT_SEARCH_VECTORS = ['context_record']
- BASE_SEARCH_VECTORS = ["label", "description", "comment", "cache_short_id",
- "cache_complete_id", "excavation_id"]
+ BASE_SEARCH_VECTORS = [
+ SearchVectorConfig("label"),
+ SearchVectorConfig("description", "local"),
+ SearchVectorConfig("comment", "local"),
+ SearchVectorConfig("cache_short_id"),
+ SearchVectorConfig("cache_complete_id"),
+ SearchVectorConfig("excavation_id"),
+ ]
objects = ExternalIdManager()
class Meta:
@@ -1280,14 +1286,27 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, QRCodeItem,
PARENT_SEARCH_VECTORS = ['base_finds']
BASE_SEARCH_VECTORS = [
- "cached_label", "label", "description", "container__location__name",
- "container__reference", "mark", "comment", "dating_comment",
- "previous_id", "denomination", "museum_id", "decoration",
- "manufacturing_place"
+ SearchVectorConfig("cached_label"),
+ SearchVectorConfig("label"),
+ SearchVectorConfig("description", "local"),
+ SearchVectorConfig("container__location__name"),
+ SearchVectorConfig("container__reference"),
+ SearchVectorConfig("mark"),
+ SearchVectorConfig("comment", "local"),
+ SearchVectorConfig("dating_comment", "local"),
+ SearchVectorConfig("previous_id"),
+ SearchVectorConfig("denomination"),
+ SearchVectorConfig("museum_id"),
+ SearchVectorConfig("decoration"),
+ SearchVectorConfig("manufacturing_place"),
]
M2M_SEARCH_VECTORS = [
- "datings__period__label", "object_types__label", "integrities__label",
- "remarkabilities__label", "material_types__label"]
+ SearchVectorConfig("datings__period__label", "local"),
+ SearchVectorConfig("object_types__label", "local"),
+ SearchVectorConfig("integrities__label"),
+ SearchVectorConfig("remarkabilities__label", "local"),
+ SearchVectorConfig("material_types__label", "local"),
+ ]
QA_EDIT = QuickAction(
url="find-qa-bulk-update", icon_class="fa fa-pencil",
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index e2882df35..3fc1a5afa 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -37,7 +37,7 @@ from ishtar_common.models import Document, GeneralType, \
ImageModel, BaseHistorizedItem, OwnPerms, HistoricalRecords, Person, \
Organization, ValueGetter, post_save_cache, ShortMenuItem, \
DashboardFormItem, ExternalIdManager, document_attached_changed, \
- HistoryModel, SearchAltName
+ HistoryModel, SearchAltName, SearchVectorConfig
from ishtar_common.utils import cached_label_changed, get_current_year, \
update_data, m2m_historization_changed
@@ -123,11 +123,23 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
]
BASE_SEARCH_VECTORS = [
- 'treatment_types__label', 'treatment_state__label', 'label', 'goal',
- 'external_id', 'comment', 'description', 'other_reference',
+ SearchVectorConfig("treatment_types__label"),
+ SearchVectorConfig("treatment_state__label"),
+ SearchVectorConfig("label"),
+ SearchVectorConfig("goal", "local"),
+ SearchVectorConfig("external_id"),
+ SearchVectorConfig("comment", "local"),
+ SearchVectorConfig("description", "local"),
+ SearchVectorConfig("other_reference"),
+ ]
+ INT_SEARCH_VECTORS = [
+ SearchVectorConfig("year"),
+ SearchVectorConfig("index"),
+ ]
+ M2M_SEARCH_VECTORS = [
+ SearchVectorConfig("downstream__cached_label"),
+ SearchVectorConfig("upstream__cached_label"),
]
- INT_SEARCH_VECTORS = ["year", "index"]
- M2M_SEARCH_VECTORS = ['downstream__cached_label', 'upstream__cached_label']
PARENT_SEARCH_VECTORS = ['person', 'organization']
objects = ExternalIdManager()
@@ -863,9 +875,15 @@ class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem,
SHOW_URL = 'show-treatmentfile'
TABLE_COLS = ['type', 'year', 'index', 'internal_reference', 'name']
BASE_SEARCH_VECTORS = [
- 'type__label', 'internal_reference', 'name', 'comment'
+ SearchVectorConfig("type__label"),
+ SearchVectorConfig("internal_reference"),
+ SearchVectorConfig("name"),
+ SearchVectorConfig("comment", "local"),
+ ]
+ INT_SEARCH_VECTORS = [
+ SearchVectorConfig("year"),
+ SearchVectorConfig("index"),
]
- INT_SEARCH_VECTORS = ['year', 'index']
PARENT_SEARCH_VECTORS = ['in_charge', 'applicant', 'applicant_organisation']
EXTRA_REQUEST_KEYS = {