| 163 | |
| 164 | |
| 165 | class FacetedSearchView(SearchView): |
| 166 | def __init__(self, *args, **kwargs): |
| 167 | # Needed to switch out the default form class. |
| 168 | if kwargs.get("form_class") is None: |
| 169 | kwargs["form_class"] = FacetedSearchForm |
| 170 | |
| 171 | super().__init__(*args, **kwargs) |
| 172 | |
| 173 | def build_form(self, form_kwargs=None): |
| 174 | if form_kwargs is None: |
| 175 | form_kwargs = {} |
| 176 | |
| 177 | # This way the form can always receive a list containing zero or more |
| 178 | # facet expressions: |
| 179 | form_kwargs["selected_facets"] = self.request.GET.getlist("selected_facets") |
| 180 | |
| 181 | return super().build_form(form_kwargs) |
| 182 | |
| 183 | def extra_context(self): |
| 184 | extra = super().extra_context() |
| 185 | extra["request"] = self.request |
| 186 | extra["facets"] = self.results.facet_counts() |
| 187 | return extra |
| 188 | |
| 189 | |
| 190 | def basic_search( |
no outgoing calls
searching dependent graphs…