summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-10-13 05:22:06 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:20:59 +0100
commit709c34707d41c907bbbcbec385c7a5be1f6f7f90 (patch)
treef3458c69995278f9c5b69c0b3ef5208221ab57ff
parent8cfbfc4d70b6ee00f278b7adc941e9d1b0ce4ecd (diff)
downloadIshtar-709c34707d41c907bbbcbec385c7a5be1f6f7f90.tar.bz2
Ishtar-709c34707d41c907bbbcbec385c7a5be1f6f7f90.zip
Syndication: query string limitation for external source
-rw-r--r--archaeological_operations/tests.py13
-rw-r--r--ishtar_common/rest.py9
2 files changed, 18 insertions, 4 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index ae012840f..cd1f6ac6d 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -4500,7 +4500,7 @@ class ApiTest(OperationInitTest, APITestCase):
self.api_user.save()
def test_api_search(self):
- self.create_api_search_model()
+ api_search_model = self.create_api_search_model()
url = reverse("api-search-operation")
data = {
"submited": 1,
@@ -4514,6 +4514,17 @@ class ApiTest(OperationInitTest, APITestCase):
j = json.loads(response.content.decode())
self.assertEqual(j['recordsTotal'], 2)
# test default filter
+ search_code_q = str(pgettext("key for text search", "patriarche"))
+ api_search_model.limit_query = '{}="28124"'.format(search_code_q)
+ api_search_model.save()
+ response = self.client.get(
+ url, format="json", HTTP_AUTHORIZATION=self.auth_token,
+ data=data
+ )
+ self.assertEqual(response.status_code, 200)
+ j = json.loads(response.content.decode())
+ self.assertEqual(j['recordsTotal'], 1, "api search limitation not effective")
+
def test_query_transformation(self):
# change query terms from a source Ishtar to match distant Ishtar
diff --git a/ishtar_common/rest.py b/ishtar_common/rest.py
index 0784f88cf..8b4419e82 100644
--- a/ishtar_common/rest.py
+++ b/ishtar_common/rest.py
@@ -37,9 +37,12 @@ class SearchAPIView(APIView):
)
search_model = self.search_model_query(request).all()[0]
if search_model.limit_query:
- # TODO
- # request.GET[] += " " + search_model.limit_query
- pass
+ query = search_model.limit_query
+ if request.GET.get("search_vector", None):
+ query += " " + request.GET.get("search_vector")
+ request.GET._mutable = True
+ request.GET["search_vector"] = query
+ request.GET._mutable = False
response = _get_item(request)
return response
#return Response({})