Skip to content

FIX12: Make all search accent and case insensitive - #445

Open
gerardm27 wants to merge 9 commits into
developfrom
fix-accent-agnostic-search
Open

FIX12: Make all search accent and case insensitive#445
gerardm27 wants to merge 9 commits into
developfrom
fix-accent-agnostic-search

Conversation

@gerardm27

@gerardm27 gerardm27 commented Aug 24, 2026

Copy link
Copy Markdown
Screen.Recording.2026-08-24.at.10.39.19.mov

What

Searching "Ma" now matches "Màdrid" (and searching "Màdrid" matches "Madrid") everywhere: all django-tables2 search filters, the hardware admin lending search, and every Django admin search_fields.

How

  • user/lookups.py registers a bilateral unaccent transform on CharField/TextField (wired up in UserConfig.ready()). Bilateral means both the column and the query value are unaccented, and the existing icontains keeps it case-insensitive.
  • Postgres (prod): uses the unaccent extension, created by migration user/0020_unaccent_extension (no-op on sqlite). Requires the extension to be available on the DB server — standard on Heroku/RDS.
  • Sqlite (dev): a Python unaccent function (NFKD normalize + strip combining marks) is registered on every connection via the connection_created signal.
  • All search sites rewritten to field__unaccent__icontains. Left alone: uuid__icontains (UUIDField) and judging's url (accents don't apply).

Drive-by fixes

Two admin searches were already broken and crashed on any query:

  • judging Room searched raw FKs challenge/main_judge → now challenge__name__unaccent, main_judge__name__unaccent
  • meals Eaten searched a nonexistent name field → now meal__name__unaccent

Testing

  • tests/test_unaccent_search.py: unaccented query matches accented name, accented+mixed-case query matches plain name, and fuzzy typo does not match.
  • Smoke-tested an accented query through get_search_results of every registered ModelAdmin — all pass on sqlite.

Not included

Fuzzy search ("mdrid" → "Madrid") — needs postgres pg_trgm with no sqlite equivalent; can be added prod-only later if wanted.

@gerardm27 gerardm27 changed the title Make all search accent and case insensitive FIX12: Make all search accent and case insensitive Aug 24, 2026
The 60% coverage gate was already failing on the adding-tests base
branch (55.56%). Adds flow tests for signup, login, logout, password
reset, email activation, and verification views, lifting total
coverage to 60.77%.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gerardm27
gerardm27 force-pushed the fix-accent-agnostic-search branch from f89cf20 to b638427 Compare August 24, 2026 08:59
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gerardm27
gerardm27 force-pushed the fix-accent-agnostic-search branch from b638427 to 9fb7c29 Compare August 24, 2026 09:01
gerardm27 and others added 2 commits August 24, 2026 11:12
Raises coverage from 60.6% to 68.3%: review voting (show next
pending, skip, comment, mark dubious), director actions (invite,
confirm, waitlist, batch invite, waitlist-all), all organizer list
views with permission checks, and user profile.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds a bilateral unaccent lookup on CharField/TextField, backed by the
postgres unaccent extension in prod and a Python-registered sqlite
function in dev. All table search filters and admin search_fields now
use field__unaccent__icontains, so queries match regardless of accents
or case in either the query or the stored value.

Also fixes two pre-existing broken admin searches: judging Room
searched raw FKs (challenge, main_judge) and meals Eaten searched a
nonexistent name field.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gerardm27
gerardm27 force-pushed the fix-accent-agnostic-search branch from 9fb7c29 to d3667a0 Compare August 24, 2026 09:12
Base automatically changed from adding-tests to develop August 26, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants