diff --git a/atlas/templates/atlas/base.html b/atlas/templates/atlas/base.html index c8974c6f..24618432 100755 --- a/atlas/templates/atlas/base.html +++ b/atlas/templates/atlas/base.html @@ -142,15 +142,16 @@ {% endif %} - - - + diff --git a/atlas/views.py b/atlas/views.py index 3f721938..0b4bfcac 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -1395,6 +1395,7 @@ def case_search_partial(request): # # If you want, I can prepare the migration, model/index changes and a # Django-code example to wire FTS into this view and tune weights. + logger.debug("case_search_partial called with GET params: %s", request.GET) q = request.GET.get("q", "") or request.GET.get("case-search-input", "") q = q.strip() @@ -3521,6 +3522,7 @@ def case_search(request): "yes", "on", ) + logger.debug(f"case_search: q={q}, collection_id={collection_id}, show_select={show_select}") collection = None if collection_id: try: @@ -3541,19 +3543,21 @@ def case_search(request): ) recent_cases = recent_qs.order_by("-created_date")[:5] - # Exclude recent cases from the main search results to avoid duplication - recent_pks = [c.pk for c in recent_cases] + cases = [] + if q: + # Exclude recent cases from the main search results to avoid duplication + recent_pks = [c.pk for c in recent_cases] - # Build the base queryset for results, apply excludes first (before slicing) - cases_qs = qs.exclude(pk__in=recent_pks) + # Build the base queryset for results, apply excludes first (before slicing) + cases_qs = qs.exclude(pk__in=recent_pks) - # Also exclude any cases that are already present in the collection - if collection is not None: - existing_pks = list(collection.cases.values_list("pk", flat=True)) - if existing_pks: - cases_qs = cases_qs.exclude(pk__in=existing_pks) + # Also exclude any cases that are already present in the collection + if collection is not None: + existing_pks = list(collection.cases.values_list("pk", flat=True)) + if existing_pks: + cases_qs = cases_qs.exclude(pk__in=existing_pks) - cases = cases_qs.order_by("title")[:30] + cases = cases_qs.order_by("title")[:30] return render( request,