Enhance exam search widget: improve filter handling and parsing in JavaScript

This commit is contained in:
Ross
2026-02-16 13:17:08 +00:00
parent 990f4534bd
commit 64103cac1e
2 changed files with 76 additions and 32 deletions
+10 -2
View File
@@ -6761,11 +6761,19 @@ def exam_search_widget(request):
# Apply optional filters from GET params to the per-model queryset
# Only include filters that were supplied in GET _and_ where the model
# actually exposes the field. This prevents models without a given
# attribute from being accidentally excluded when a default filter
# value is always sent by the widget JS.
extra_filters = {}
for pname in ("archive", "open_access", "exam_mode", "candidates_only"):
val = _get_bool_param(pname)
if val is not None:
extra_filters[pname] = val
if val is None:
continue
# Only include the filter if the model defines the field
if not _field_exists(model, pname):
continue
extra_filters[pname] = val
results = []
logger.error(f"Exam search widget: model={model}, q='{q}', extra_filters={extra_filters}, initial_count={qs.count() if qs is not None else 'N/A'}")