From 634ffbb0f9037033bc99f289a2baa4cbbf6c9c03 Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Mon, 6 Nov 2023 15:36:05 -0600 Subject: [PATCH] Use homedir to isolate the search. --- server/portal/apps/site_search/api/unit_test.py | 2 +- server/portal/apps/site_search/api/views.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/portal/apps/site_search/api/unit_test.py b/server/portal/apps/site_search/api/unit_test.py index b871a3e70..3c3911428 100644 --- a/server/portal/apps/site_search/api/unit_test.py +++ b/server/portal/apps/site_search/api/unit_test.py @@ -144,7 +144,7 @@ def test_file_search_util(mock_file_search, regular_user): [{'name': 'testfile', 'path': '/path/to/testfile'}]} client = regular_user.tapis_oauth.client - res = files_search(client, 'test_query', 'test_system') + res = files_search(client, 'test_query', 'test_system', '/',) mock_file_search.assert_called_with(client, 'test_system', '/', query_string='test_query', diff --git a/server/portal/apps/site_search/api/views.py b/server/portal/apps/site_search/api/views.py index 7203e15e2..70cf3cefa 100644 --- a/server/portal/apps/site_search/api/views.py +++ b/server/portal/apps/site_search/api/views.py @@ -36,8 +36,8 @@ def cms_search(query_string, offset=0, limit=10): return total, results -def files_search(client, query_string, system, filter=None, offset=0, limit=10): - res = search_operation(client, system, '/', offset=offset, limit=limit, +def files_search(client, query_string, system, path, filter=None, offset=0, limit=10): + res = search_operation(client, system, path, offset=offset, limit=limit, query_string=query_string, filter=filter) return (res['count'], res['listing']) @@ -65,7 +65,7 @@ def get(self, request, *args, **kwargs): and ('siteSearchPriority' in conf and conf['siteSearchPriority'] is not None)) client = request.user.tapis_oauth.client if (request.user.is_authenticated and request.user.profile.setup_complete) else service_account() (public_total, public_results) = \ - files_search(client, qs, public_conf['system'], filter=filter, + files_search(client, qs, public_conf['system'], public_conf.get("homeDir", "/"), filter=filter, offset=offset, limit=limit) response['public'] = {'count': public_total, 'listing': public_results, @@ -84,7 +84,7 @@ def get(self, request, *args, **kwargs): and ('siteSearchPriority' in conf and conf['siteSearchPriority'] is not None)) client = request.user.tapis_oauth.client (community_total, community_results) = \ - files_search(client, qs, community_conf['system'], filter=filter, + files_search(client, qs, community_conf['system'], community_conf.get("homeDir", "/"), filter=filter, offset=offset, limit=limit) response['community'] = {'count': community_total,