diff --git a/samplesheets/plugins.py b/samplesheets/plugins.py index cd40be74..2ed0748d 100644 --- a/samplesheets/plugins.py +++ b/samplesheets/plugins.py @@ -21,6 +21,7 @@ ProjectAppPluginPoint, ProjectModifyPluginMixin, PluginObjectLink, + PluginSearchResult, get_backend_api, ) from projectroles.utils import build_secret @@ -448,32 +449,34 @@ def search(self, search_terms, user, search_type=None, keywords=None): :param user: User object for user initiating the search :param search_type: String :param keywords: List (optional) - :return: Dict + :return: List of PluginSearchResult objects """ irods_backend = get_backend_api('omics_irods') - results = {} + ret = [] # Materials if not search_type or search_type in MATERIAL_SEARCH_TYPES: item_types = ['SOURCE', 'SAMPLE'] if search_type in MATERIAL_SEARCH_TYPES: item_types = [search_type.upper()] - results['materials'] = { - 'title': 'Sources and Samples', - 'search_types': ['source', 'sample'], - 'items': self._get_search_materials( + r = PluginSearchResult( + category='materials', + title='Sources and Samples', + search_types=['source', 'sample'], + items=self._get_search_materials( search_terms, user, keywords, item_types ), - } + ) + ret.append(r) # iRODS files if irods_backend and (not search_type or search_type == 'file'): - results['files'] = { - 'title': 'Sample Files in iRODS', - 'search_types': ['file'], - 'items': self._get_search_files( - search_terms, user, irods_backend - ), - } - return results + r = PluginSearchResult( + category='files', + title='Sample Files in iRODS', + search_types=['file'], + items=self._get_search_files(search_terms, user, irods_backend), + ) + ret.append(r) + return ret def get_project_list_value(self, column_id, project, user): """