Skip to content

Commit

Permalink
Update search form domain filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchdawson1982 committed Jul 26, 2024
1 parent 68a09af commit 71f2e03
Showing 1 changed file with 14 additions and 2 deletions.
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]:
"""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

0 comments on commit 71f2e03

Please sign in to comment.