summaryrefslogtreecommitdiff
path: root/archaeological_finds/models_treatments.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/models_treatments.py')
-rw-r--r--archaeological_finds/models_treatments.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index 1f2ad1c0f..071d80af1 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -74,7 +74,11 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
'person__cached_label',
'start_date', 'downstream_cached_label',
'upstream_cached_label')
- REVERSED_BOOL_FIELDS = ['documents__image__isnull']
+ REVERSED_BOOL_FIELDS = [
+ 'documents__image__isnull',
+ 'documents__associated_file__isnull',
+ 'documents__associated_url__isnull',
+ ]
EXTRA_REQUEST_KEYS = {
"downstream_cached_label": "downstream__cached_label",
"upstream_cached_label": "upstream__cached_label",
@@ -115,10 +119,6 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
pgettext_lazy("key for text search", "index"),
'index'
),
- 'documents__image__isnull': SearchAltName(
- pgettext_lazy("key for text search", "has-image"),
- 'documents__image__isnull'
- ),
'treatment_types': SearchAltName(
pgettext_lazy("key for text search", "type"),
'treatment_types__label__iexact'
@@ -129,6 +129,7 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
+ ALT_NAMES.update(DocumentItem.ALT_NAMES)
HISTORICAL_M2M = [
'treatment_types',
]
@@ -143,6 +144,9 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
SearchVectorConfig("description", "local"),
SearchVectorConfig("other_reference"),
]
+ PROPERTY_SEARCH_VECTORS = [
+ SearchVectorConfig("year_index"),
+ ]
INT_SEARCH_VECTORS = [
SearchVectorConfig("year"),
SearchVectorConfig("index"),
@@ -248,6 +252,10 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
def natural_key(self):
return (self.external_id, )
+ @property
+ def year_index(self):
+ return "{}-{}".format(self.year, self.index)
+
@classmethod
def get_query_owns(cls, ishtaruser):
return (Q(history_creator=ishtaruser.user_ptr) |
@@ -907,6 +915,11 @@ class TreatmentFile(DashboardFormItem, ClosedItem, DocumentItem,
"in_charge__pk": "in_charge__pk", # used by dynamic_table_documents
"applicant__pk": "applicant__pk", # used by dynamic_table_documents
}
+ REVERSED_BOOL_FIELDS = [
+ 'documents__image__isnull',
+ 'documents__associated_file__isnull',
+ 'documents__associated_url__isnull',
+ ]
# alternative names of fields for searches
ALT_NAMES = {
'name': SearchAltName(
@@ -959,6 +972,7 @@ class TreatmentFile(DashboardFormItem, ClosedItem, DocumentItem,
),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
+ ALT_NAMES.update(DocumentItem.ALT_NAMES)
DATED_FIELDS = ['exhibition_start_date__lte',
'exhibition_start_date__gte',