Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update search form domain filters #597

Merged
merged 8 commits into from
Jul 29, 2024
16 changes: 14 additions & 2 deletions home/forms/search.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from copy import deepcopy
from urllib.parse import urlencode

from data_platform_catalogue.search_types import ResultType
from data_platform_catalogue.search_types import ListDomainOption, ResultType
from django import forms

from ..models.domain_model import Domain, DomainModel
from ..service.list_domain_fetcher import ListDomainFetcher
from ..service.search_facet_fetcher import SearchFacetFetcher
from ..service.search_tag_fetcher import SearchTagFetcher

Expand All @@ -19,6 +20,17 @@ def get_domain_choices() -> list[Domain]:
return choices


def get_list_domain_choices() -> list[Domain]:
mitchdawson1982 marked this conversation as resolved.
Show resolved Hide resolved
"""Make ListDomains API call to obtain domain choices"""
choices = [
Domain("", "All domains"),
]
list_domain_options: list[ListDomainOption] = ListDomainFetcher().fetch()
domains: list[Domain] = [Domain(d.urn, d.name) for d in list_domain_options]
choices.extend(domains)
return choices


def get_subdomain_choices() -> list[Domain]:
choices = [Domain("", "All subdomains")]
facets = SearchFacetFetcher().fetch()
Expand Down Expand Up @@ -86,7 +98,7 @@ class SearchForm(forms.Form):
),
)
domain = forms.ChoiceField(
choices=get_domain_choices,
choices=get_list_domain_choices,
required=False,
widget=forms.Select(
attrs={
Expand Down