summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models_finds.py1
-rw-r--r--archaeological_finds/tests.py29
2 files changed, 30 insertions, 0 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index fff692917..7a8715f1b 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -1259,6 +1259,7 @@ class Find(
"museum_allocation_date__lte",
"museum_allocation_date__gte",
]
+ NUMBER_FIELDS = ["base_finds__context_record__operation__year"]
BASE_REQUEST = {"downstream_treatment__isnull": True}
EXTRA_REQUEST_KEYS = {
"all_base_finds__context_record": "base_finds__context_record__context_record_tree_parent__cr_parent_id",
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index 60dcb5a5d..346aa0b1e 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -1591,6 +1591,35 @@ class FindSearchTest(FindInit, TestCase, SearchText):
result = [('-{}="{}"'.format(key, "*"), models.Find.objects.count() - 1)]
self._test_search(c, result, context="-* description Search")
+ def test_number_search(self):
+ # test year search with "=>" notation
+ ope1 = self.operations[0]
+ ope1.year = 2000
+ ope1.save()
+ ope2 = self.operations[1]
+ ope2.year = 2020
+ ope2.save()
+ self.create_finds()
+ self.create_finds()
+
+ c = Client()
+ c.login(username=self.username, password=self.password)
+
+ key = str(pgettext_lazy("key for text search", "year"))
+
+ result = [('{}="{}"'.format(key, 2000), 3)]
+ self._test_search(c, result, context="Exact year search")
+ result = [('{}="{}"'.format(key, 2020), 1)]
+ self._test_search(c, result, context="Exact year search")
+ result = [('{}=>"{}"'.format(key, 2019), 1)]
+ self._test_search(c, result, context="=> year search")
+ result = [('{}=>"{}"'.format(key, 1999), 4)]
+ self._test_search(c, result, context="=> year search")
+ result = [('{}=<"{}"'.format(key, 2001), 3)]
+ self._test_search(c, result, context="=< year search")
+ result = [('{}=>"{}" {}=<"{}"'.format(key, 2001, key, 2022), 1)]
+ self._test_search(c, result, context="=> and =< year search")
+
def test_address_operation_search(self):
operation = self.operations[0]
operation.address = "Street somewhere 29478 NOWHERE"