Enhance exam search widget: improve filter handling and parsing in JavaScript
This commit is contained in:
+10
-2
@@ -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'}")
|
||||
|
||||
Reference in New Issue
Block a user