diff --git a/home/forms/search.py b/home/forms/search.py index 6d1dad96..ba9bd468 100644 --- a/home/forms/search.py +++ b/home/forms/search.py @@ -8,7 +8,7 @@ def get_domain_choices() -> list[tuple[str, str]]: """Make API call to obtain domain choices""" # TODO: pull in the domains from the catalogue client # facets = client.search_facets() - # domain_list = facets.options("domain") + # domain_list = facets.options("domains") return [ ("", "All Domains"), ("urn:li:domain:HMCTS", "HMCTS"), diff --git a/home/service/search.py b/home/service/search.py index 45c5fc13..3e9c8a06 100644 --- a/home/service/search.py +++ b/home/service/search.py @@ -31,14 +31,10 @@ def __init__(self, form: SearchForm, page: str, items_per_page: int = 20): self.context = self._get_context() @staticmethod - def _build_filter_strings( + def _build_custom_property_filter( filter_param: str, filter_value_list: list[str] ) -> list[str]: - return ( - [f"{filter_param}{filter_value}" for filter_value in filter_value_list] - if filter_value_list - else [] - ) + return [f"{filter_param}{filter_value}" for filter_value in filter_value_list] def _get_search_results(self, page: str, items_per_page: int): if self.form.is_bound: @@ -50,10 +46,10 @@ def _get_search_results(self, page: str, items_per_page: int): sort = form_data.get("sort", "relevance") domain = form_data.get("domain", "") domains_and_subdomains = domains_with_their_subdomains(domain) - classifications = self._build_filter_strings( + classifications = self._build_custom_property_filter( "sensitivityLevel=", form_data.get("classifications", []) ) - where_to_access = self._build_filter_strings( + where_to_access = self._build_custom_property_filter( "whereToAccessDataset=", form_data.get("where_to_access", []) ) filter_value = [] diff --git a/home/templatetags/lookup.py b/home/templatetags/lookup.py index 2f67d140..ea9f839e 100644 --- a/home/templatetags/lookup.py +++ b/home/templatetags/lookup.py @@ -1,5 +1,6 @@ from home.templatetags.markdown import register + @register.filter def lookup(list, lookup_dict): - return sorted([lookup_dict.get(item)for item in list]) + return sorted([lookup_dict.get(item) for item in list]) diff --git a/tests/conftest.py b/tests/conftest.py index 4f723701..167b89ce 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -47,7 +47,6 @@ def generate_page(page_size=20, result_type: ResultType = None): results.append( SearchResult( id=fake.unique.name(), - result_type=choice((ResultType.DATA_PRODUCT, ResultType.TABLE)), result_type=( choice((ResultType.DATA_PRODUCT, ResultType.TABLE)) if result_type is None