diff options
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 |
commit | ba24111f03c601458f2ede5447c57fc7b22e6246 (patch) | |
tree | f3458c69995278f9c5b69c0b3ef5208221ab57ff | |
parent | 3962e32e1d1d7517b3c625df5f85770285014091 (diff) | |
download | Ishtar-ba24111f03c601458f2ede5447c57fc7b22e6246.tar.bz2 Ishtar-ba24111f03c601458f2ede5447c57fc7b22e6246.zip |
Syndication: query string limitation for external source
-rw-r--r-- | archaeological_operations/tests.py | 13 | ||||
-rw-r--r-- | ishtar_common/rest.py | 9 |
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({}) |