Skip to content

Add web UI for browsing NC voter registration and history data#19

Merged
copelco merged 17 commits into
mainfrom
frontendui
Apr 17, 2026
Merged

Add web UI for browsing NC voter registration and history data#19
copelco merged 17 commits into
mainfrom
frontendui

Conversation

@copelco
Copy link
Copy Markdown
Member

@copelco copelco commented Apr 17, 2026

Adds a DaisyUI/Dracula-themed web interface for exploring NC State Board of Elections voter data:

  • Homepage with an interactive SVG county map, county search with datalist, DaisyUI stats cards showing voter/event counts, and a chatbot card linking to the LibreChat instance (CHATBOT_URL setting)
  • County Registrations page with a single-query aggregated breakdown of active voters by gender, party, race, ethnicity, and status, plus a sample voter table
  • Voter History page showing all election events for a given NCID with a voter demographics card
  • Forms (CountyForm, VoterHistoryForm) for validated, cleaned URL/query inputs
  • Model indexes on VoterView.county_name and VoterEventView.ncid for query performance
  • django-debug-toolbar added for development; django.contrib.humanize for number formatting
  • cache_page on county and voter history views; homepage data fetched fresh each request

copelco added 11 commits April 17, 2026 11:04
- Home page with interactive SVG county map and search form
- County registrations page with single-query aggregate stats
- Voter history page sorted by election date desc
- CountyForm and VoterHistoryForm with clean/validate methods
- 13 tests covering forms, views, aggregates, and 404 cases
- Add django-debug-toolbar (dev only) with INSTALLED_APPS, middleware, and URL wiring
- Restrict gender/party/race/ethnicity counts to active voters (registration_status_code='A')
- Right-align counts column and apply intcomma filter in county registrations table
- Expand homepage hero with site description and NCSBE data source link
- Add county_name index on VoterView and ncid index on VoterEventView
  via conditional RunSQL migration (skips if views don't exist yet)
- voter_history: evaluate queryset once with list() instead of
  .exists() + iteration (saves a second DB round-trip)
- Replace browser-native SVG <title> tooltip (1s delay) with instant
  CSS-positioned floating div on mouseenter/mousemove/mouseleave
- Delete migration 0003 (django-pgviews handles indexes via sync_pgviews)
- Simplify Meta.indexes: remove ClassVar annotation, drop explicit names
- SVG map: remove green dot artifacts and yellow county fills
- SVG map: scale to 100% width with viewBox for responsive display
- County registrations: indent metric rows with pl-6 under category headers
- SVG map: highlight county pink (#ff79c6, dracula theme) on hover,
  restoring original fill on mouse leave
- County search: add <datalist> with all 100 counties so users can
  autocomplete without typing the full name
- Add test verifying counties context is passed to home view
- Home view: pass voter_count and event_count to template
- Home template: add summary cards with intcomma counts linking to
  NCSBE data sources, wrapped in {% cache 3600 "home_summary" %}
- Add CC BY-SA 3.0 attribution for GayTenn/Wikimedia map below SVG
- Add test verifying voter_count and event_count in home view context
- county_registrations: two-column grid (stats left, sample voters right),
  both in cards with table-xs for compact display, deeper pl-8 indent
- base: add GitHub icon link (CC BY-SA SVG) to navbar-end
- voter_history: no longer 404 when events are empty; show "No voting
  history found" message instead
- voter_history: add Demographics card (county, gender, status, party,
  race, ethnicity, birth year, age, reg. year) from VoterView
- voter_history: compact table-xs, two-column layout (demographics + history)
- county_registrations: add hover:bg-base-300 to all data rows
- Update tests: rename 404 test to reflect new 200 behavior, add
  demographics context test and empty events test
- Add @cache_page(3600) to all 3 views; remove redundant {% cache %} block
- Add CHATBOT_URL setting (from env) and "Ask the Chatbot" button on homepage
- Sample voters: increase from 10 to 25, add hover:bg-base-300 to rows
- Deployment: document CHATBOT_URL in Helm values.yaml
- Tests: add disable_cache autouse fixture (DummyCache) so context is
  accessible; add chatbot_url and sample_voters count tests
…unts

- Move chatbot button into a dedicated card showing active ToolModel
  entries (tool name → model name) so users can see which model
  providers are configured
- Remove @cache_page from home view (dynamic ToolModel content)
- Wrap voter/event count cards in {% cache 3600 "home_counts" %}
  template fragment to preserve caching for the expensive DB counts
@copelco copelco changed the title Frontendui Add web UI for browsing NC voter registration and history data Apr 17, 2026
copelco added 6 commits April 17, 2026 13:09
- Replace {% cache %} template block with cache.get_or_set() in the
  home view for voter_count and event_count — the template block only
  cached rendered HTML while the DB queries still ran on every request
- Change "Ask the Chatbot" button to btn-primary
- Change voter history stat color from text-secondary to text-accent
- Add test verifying counts are stored in cache after home page load
debug_toolbar is a dev-only dependency; without DEBUG=False explicitly
set, it was included in INSTALLED_APPS at runtime causing ModuleNotFoundError
@copelco copelco marked this pull request as ready for review April 17, 2026 18:00
@copelco copelco merged commit d2d31cc into main Apr 17, 2026
2 checks passed
@copelco copelco deleted the frontendui branch April 17, 2026 18:00
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.

1 participant