Skip to content

Commit 31ab6ff

Browse files
committed
Apply relation filter even when it's not a custom facet
1 parent 814ca3d commit 31ab6ff

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

calisphere/search_form.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,29 @@ def __init__(self, request, collection):
283283
self.implicit_filter = [collection.basic_filter]
284284

285285

286-
class ESCollectionForm(CollectionForm):
286+
class ESCollectionForm(SearchForm):
287287
"""ElasticSearch Search Form for /collections/<col_id>/ page"""
288288
facet_filter_fields = [
289289
ff.ESTypeFF,
290290
ff.ESDecadeFF
291291
]
292292
index = 'es'
293293

294+
def __init__(self, request, collection):
295+
super().__init__(request)
296+
297+
self.collection = collection
298+
self.facet_filter_types += [
299+
ff_field(request) for ff_field in collection.custom_facets
300+
]
301+
302+
# If relation_ss is not already defined as a custom facet, and is
303+
# included in search parameters, add the relation_ss facet implicitly
304+
if not collection.custom_facets:
305+
if request.get('relation_ss'):
306+
self.facet_filter_types.append(ff.ESRelationFF(request))
307+
self.implicit_filter = [collection.basic_filter]
308+
294309

295310
class CarouselForm(SearchForm):
296311
"""Search Form for the carousel on an /item/<item_id>/ page

0 commit comments

Comments
 (0)