summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-07-09 11:53:00 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-07-09 11:53:00 +0200
commit915e294bcacf7bf79c90fc7ffb46f34d3902aaec (patch)
tree1e8aab73d44e23139571665e35cd722ed3afca28
parentd7effe6fae485d3b2d4bfbe1315bd3acf1d85e41 (diff)
downloadIshtar-915e294bcacf7bf79c90fc7ffb46f34d3902aaec.tar.bz2
Ishtar-915e294bcacf7bf79c90fc7ffb46f34d3902aaec.zip
🐛 fix many date and numeric searches (refs #5928)
-rw-r--r--archaeological_finds/fixtures/initial_data-fr.json2
-rw-r--r--archaeological_finds/migrations/0126_fix_treatment_file_exhibition.py21
-rw-r--r--archaeological_finds/models_finds.py56
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html4
-rw-r--r--archaeological_finds/templates/ishtar/sheet_museum_find.html4
-rw-r--r--archaeological_operations/models.py2
-rw-r--r--ishtar_common/models.py2
-rw-r--r--ishtar_common/views_item.py15
8 files changed, 50 insertions, 56 deletions
diff --git a/archaeological_finds/fixtures/initial_data-fr.json b/archaeological_finds/fixtures/initial_data-fr.json
index 91c8c0c91..4b0c75553 100644
--- a/archaeological_finds/fixtures/initial_data-fr.json
+++ b/archaeological_finds/fixtures/initial_data-fr.json
@@ -7036,7 +7036,7 @@
"model": "archaeological_finds.treatmentfiletype",
"fields": {
"label": "Demande de pr\u00eat pour exposition",
- "txt_idx": "loan_demand_exposure",
+ "txt_idx": "loan-for-exhibition",
"comment": "",
"available": true
}
diff --git a/archaeological_finds/migrations/0126_fix_treatment_file_exhibition.py b/archaeological_finds/migrations/0126_fix_treatment_file_exhibition.py
new file mode 100644
index 000000000..f9d252e0d
--- /dev/null
+++ b/archaeological_finds/migrations/0126_fix_treatment_file_exhibition.py
@@ -0,0 +1,21 @@
+# Generated by Django 2.2.24 on 2024-07-09 11:11
+
+from django.db import migrations
+
+
+SQL = """
+UPDATE archaeological_finds_treatmentfiletype
+ SET txt_idx='loan-for-exhibition'
+ WHERE txt_idx='loan_demand_exposure'
+"""
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0125_data_migration_communicability_functionalarea'),
+ ]
+
+ operations = [
+ migrations.RunSQL(SQL)
+ ]
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 5f8c30701..68c988517 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -1241,7 +1241,7 @@ class Find(
}
DATED_FIELDS = BaseHistorizedItem.DATED_FIELDS + [
- "treatments__file__end_date",
+ "basket__treatment_files__end_date",
"treatments__end_date",
"base_finds__discovery_date",
"base_finds__discovery_date_taq",
@@ -1264,11 +1264,16 @@ class Find(
"circumference",
"volume",
"weight",
+ "find_number",
+ "min_number_of_individuals",
+ "datings__start_date",
+ "datings__end_date",
"clutter_long_side",
"clutter_short_side",
"clutter_height",
- "estimated_value",
- "insurance_value",
+ "museum_inventory_entry_year",
+ "museum_inventory_quantity",
+ "museum_observed_quantity",
] + GeographicSubTownItem.NUMBER_FIELDS
BASE_REQUEST = {"downstream_treatment__isnull": True}
EXTRA_REQUEST_KEYS = {
@@ -1443,7 +1448,7 @@ class Find(
"loan": SearchAltName(pgettext_lazy("key for text search", "loan"), query_loan),
"treatments_file_end_date": SearchAltName(
pgettext_lazy("key for text search", "treatment-file-end-date"),
- "treatments__file__end_date",
+ "basket__treatment_files__end_date",
),
"treatments_end_date": SearchAltName(
pgettext_lazy("key for text search", "treatment-end-date"),
@@ -1531,43 +1536,6 @@ class Find(
pgettext_lazy("key for text search", "conservatory-comment"),
"conservatory_comment__iexact",
),
- "length__lower": SearchAltName(
- pgettext_lazy("key for text search", "length-lower"), "length__lte"
- ),
- "width__lower": SearchAltName(
- pgettext_lazy("key for text search", "width-lower"), "width__lte"
- ),
- "height__lower": SearchAltName(
- pgettext_lazy("key for text search", "height-lower"), "height__lte"
- ),
- "thickness__lower": SearchAltName(
- pgettext_lazy("key for text search", "thickness-lower"), "thickness__lte"
- ),
- "diameter__lower": SearchAltName(
- pgettext_lazy("key for text search", "diameter-lower"), "diameter__lte"
- ),
- "circumference__lower": SearchAltName(
- pgettext_lazy("key for text search", "circumference-lower"),
- "circumference__lte",
- ),
- "volume__lower": SearchAltName(
- pgettext_lazy("key for text search", "volume-lower"), "volume__lte"
- ),
- "weight__lower": SearchAltName(
- pgettext_lazy("key for text search", "weight-lower"), "weight__lte"
- ),
- "clutter_long_side__lower": SearchAltName(
- pgettext_lazy("key for text search", "clutter-long-side-lower"),
- "clutter_long_side__lte",
- ),
- "clutter_short_side__lower": SearchAltName(
- pgettext_lazy("key for text search", "clutter-short-side-lower"),
- "clutter_short_side__lte",
- ),
- "clutter_height__lower": SearchAltName(
- pgettext_lazy("key for text search", "clutter-height-lower"),
- "clutter_height__lte",
- ),
"length": SearchAltName(
pgettext_lazy("key for text search", "length"), "length"
),
@@ -1702,7 +1670,7 @@ class Find(
pgettext_lazy("key for text search", "museum-custodian-institution"),
"museum_custodian_institution__name__iexact",
related_name="museum_custodian_institution"
- ),
+ ),
"museum_depositor_inventory_number": SearchAltName(
pgettext_lazy("key for text search", "museum-depositor-inventory-number"),
"museum_depositor_inventory_number__iexact"
@@ -1782,11 +1750,11 @@ class Find(
),
"museum_inventory_quantity": SearchAltName(
pgettext_lazy("key for text search", "museum-inventory-quantity"),
- "museum_inventory_quantity__iexact"
+ "museum_inventory_quantity"
),
"museum_observed_quantity": SearchAltName(
pgettext_lazy("key for text search", "museum-observed-quantity"),
- "museum_observed_quantity__iexact"
+ "museum_observed_quantity"
),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index c0f525dfa..27d106fbd 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -48,7 +48,6 @@
{% trans "Identification / Description" %}
</a>
</li>
- {% if display_warehouse_treatments %}
<li class="nav-item">
<a class="nav-link" id="{{window_id}}-warehouse-tab"
data-toggle="tab" href="#{{window_id}}-warehouse" role="tab"
@@ -56,7 +55,6 @@
{% trans "Preservation / Treatments" %}
</a>
</li>
- {% endif %}
{% if display_documents %}
<li class="nav-item">
<a class="nav-link" id="{{window_id}}-documents-tab"
@@ -271,7 +269,6 @@
{% include "ishtar/blocks/sheet_creation_section.html" %}
</div>
</div>
- {% if display_warehouse_treatments %}
<div class="tab-pane fade" id="{{window_id}}-warehouse"
role="tabpanel" aria-labelledby="{{window_id}}-warehouse-tab">
{% comment %}
@@ -529,7 +526,6 @@
</table>
{% endif %}
</div>
- {% endif %}
{% if display_documents %}
<div class="tab-pane fade" id="{{window_id}}-documents"
role="tabpanel" aria-labelledby="{{window_id}}-documents-tab">
diff --git a/archaeological_finds/templates/ishtar/sheet_museum_find.html b/archaeological_finds/templates/ishtar/sheet_museum_find.html
index 4006973d7..73e76d8bd 100644
--- a/archaeological_finds/templates/ishtar/sheet_museum_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_museum_find.html
@@ -48,7 +48,6 @@
{% trans "Archaeological context" %}
</a>
</li>
- {% if display_warehouse_treatments %}
<li class="nav-item">
<a class="nav-link" id="{{window_id}}-warehouse-tab"
data-toggle="tab" href="#{{window_id}}-warehouse" role="tab"
@@ -56,7 +55,6 @@
{% trans "Preservation / Treatments" %}
</a>
</li>
- {% endif %}
{% if display_documents %}
<li class="nav-item">
<a class="nav-link" id="{{window_id}}-documents-tab"
@@ -297,7 +295,6 @@
</div>
</div>
- {% if display_warehouse_treatments %}
<div class="tab-pane fade" id="{{window_id}}-warehouse"
role="tabpanel" aria-labelledby="{{window_id}}-warehouse-tab">
{% comment %}
@@ -555,7 +552,6 @@
</table>
{% endif %}
</div>
- {% endif %}
{% if display_documents %}
<div class="tab-pane fade" id="{{window_id}}-documents"
role="tabpanel" aria-labelledby="{{window_id}}-documents-tab">
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 7e3b0254f..60a9dbfca 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -2651,7 +2651,7 @@ class AdministrativeAct(DocumentItem, BaseHistorizedItem, OwnPerms, ValueGetter,
"documents__associated_url__isnull",
"documents__associated_file__isnull",
]
- NUMBER_FIELDS = ["year", "index"]
+ NUMBER_FIELDS = ["signature_date__year", "index"]
RELATIVE_SESSION_NAMES = [
("operation", "operation__pk"),
("file", "associated_file__pk"),
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index def056425..9eeea5d66 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -4257,7 +4257,7 @@ class Document(
]
BOOL_FIELDS = BaseHistorizedItem.BOOL_FIELDS + ["duplicate"]
-
+ NUMBER_FIELDS = ["operations__year"]
COL_LABELS = {
"authors__cached_label": _("Authors"),
"complete_identifier": _("Identifier"),
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index 9e347a08d..fbe522b1c 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -2336,7 +2336,6 @@ def get_item(
distinct_queries,
query_parameters,
)
-
search_vector = ""
if "search_vector" in dct:
search_vector = dct.pop("search_vector")
@@ -2366,6 +2365,20 @@ def get_item(
if tmp_excluded:
excluded_dct.update(tmp_excluded)
+ # dated_fields, number_fields
+ # ['signature_date', ...], ['signature_date__year', ...]
+ # -> remove 'signature_date'
+ filtered_dated_fields = []
+ for field_name in my_dated_fields:
+ exc = False
+ for number_field in my_number_fields:
+ if number_field.startswith(field_name):
+ exc = True
+ break
+ if not exc:
+ filtered_dated_fields.append(field_name)
+ my_dated_fields = filtered_dated_fields
+
_manage_dated_fields(my_dated_fields, dct)
_manage_dated_fields(my_dated_fields, excluded_dct)