Fix Django/Wagtail search-bar parity bugs (container, wasmPath, Amazee trigger, per-page language)#2
Open
jeremyandrews wants to merge 1 commit into
Open
Conversation
…e trigger, per-page language)
Brings the Django adapter in line with the PHP adapters on four fronts surfaced
by the GitMastery demo:
- {% scolta_search %} now emits a `container` selector in window.scolta matching
the rendered mount div. scolta.js auto-init reads it to find its mount point;
without it the markup rendered but the search box never did.
- {% scolta_search %} now sets `wasmPath` to the full WASM glue module
(.../wasm/scolta_core.js), not the containing directory — scolta.js does
import(wasmPath) directly, so a bare directory 404s.
- Amazee auto-provisioning now triggers on a key gate, not a provider gate:
maybe_auto_provision() provisions a free trial whenever no API key is
configured, regardless of ai_provider (mirrors the PHP getApiKeySource()
=== 'none' contract). An explicit key always wins. Previously it required
ai_provider == 'amazee', so the default 'anthropic' never provisioned and AI
silently degraded.
- SearchableMixin.to_searchable_content() derives the per-page filter language
from a Wagtail locale (self.locale.language_code) when present, so
multilingual sites populate the language facet per page instead of collapsing
every page into the default bucket. Plain models keep the default; explicit
overrides must pass language= themselves.
Tests: browser-layer search-bar mount regression (Playwright, skips when
chromium is absent) + container/wasmPath config guards; Amazee key-gate trigger
contract (default provider + no key provisions, explicit key no-ops, stored
creds no-op); Wagtail-locale language derivation. A conftest autouse fixture
keeps AI-view tests hermetic now that no key triggers provisioning. CI installs
chromium for the browser test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings the Django adapter in line with the PHP adapters, fixing four issues surfaced by the GitMastery (
demos/git-manual-django) demo. Each is paired with a regression test at the layer that would have caught it.Fixes
container) —{% scolta_search %}now emits acontainerCSS selector inwindow.scoltamatching the rendered mount<div>.scolta.jsauto-init reads it to locate its mount point; without it the markup rendered but the search box never did. (carried in from an earlier session; now under test)wasmPath— now points at the full WASM glue module (…/wasm/scolta_core.js) rather than the containing directory, becausescolta.jscallsimport(wasmPath)directly and a bare directory 404s. (carried in; now under test)maybe_auto_provision()now gates on no API key configured instead ofai_provider == 'amazee'. This mirrors the PHP adapters (ScoltaAiService::createClientlazy-provisions whenevergetApiKeySource() === 'none'): a site with no key gets the free Amazee trial automatically; an explicit key always wins. Previously the defaultanthropicprovider never provisioned and AI silently degraded.SearchableMixin.to_searchable_content()derives the per-page filterlanguagefrom a Wagtail locale (self.locale.language_code) when present, so multilingual sites populate thelanguagefacet per page instead of collapsing every page into the index's single bucket. Plain Django models without a locale keep theContentItemdefault; explicit overrides must passlanguage=themselves (documented in the mixin).Tests
tests/test_search_browser.py(new) — browser-layer mount regression via Playwright; skips cleanly when chromium/playwright is absent.tests/browser_urls.py(new) serves the real assets.tests/test_adapter.py—container+wasmPathconfig guards.tests/test_amazee_django.py— key-gate trigger contract: default provider (anthropic) + no key + empty storage provisions; explicit key no-ops; already-stored creds no-op.tests/test_wagtail.py— Wagtail-locale language derivation; plain model keeps the default.tests/conftest.py— autouse fixture keeps AI-view tests hermetic now that "no key" triggers provisioning (the Amazee unit tests import the function directly and inject a fake client, so they're unaffected).playwright install --with-deps chromiumstep added before the test run.Testing done
ruff check src testsclean;pytest70 passed locally.https://gitmastery-django.ddev.site/) on the editable package install:/serves the search UI in main content, not the header; results render below the header band (no overlap).languagefilter map:{en: 286, es/fr/it/de: 285}(was{en: 1426})./de//es//fr//it/URLs; an Italian search from/it/returns only/it/URLs (auto language filter).ai_configured: true(provideranthropic → openaivia the Amazee trial) after one search — the free trial provisions with no key set.