Commit 167f4e1
Create "Compare" And "More" Pages In Wagtail (#1241)
* update get_locales_for_cms_page() to also return fallback locale codes
* add a utility function to find the fallback page for a locale
* add a migration to ensure expected Locales exist in database
* update FALLBACK_LOCALES mapping in settings to match expected locale fallback pattern
* update CMSLocaleFallbackMiddleware to serve content from a fallback locale when the requested locale page is not found
* update SpringfieldLocale.get_active to find fallback locale if needed
Note: this logic shouldn't be needed, since all of
the locales should be present in the database, but
in case one of the locale records is removed from
the database, but the locale is still referenced
in the code (for example, in the settings), this
logic will handle it.
* update i18n context processor to return a CANONICAL_LANG
CANONICAL_LANG matches LANG, unless a page is served
for a fallback locale. In this case, the template
can determine which context variable (LANG or
CANONICAL_LANG) to use in each relevant place.
* update SpringfieldLinkBlock to return expected page URLs
when a user requests a page and is given content
for a fallback locale, the page links in the
content should match the requested URL's locale.
* avoid bug of always returning a 200 response by reverting commit 356d331
* add tests for changes to get_locale() and render()
* make sure that locales created in migration are translations of root page
* update get_locale_options to return alias locales that have fallback locales
* make sure canonical href points to appropriate URL for content
* add a test that alias locale pages do not appear in the sitemap
* for consistency, make sure non-Wagtail pages also serve fallback content from alias locale URL when alias locale has no content
* serve fallback locale content even when alias Locale does not exist in the database
* make sure page links in link block return alias locale URLs even when alias Locale does not exist in the database
* update tests that rely on FALLBACK_LOCALES to explicitly set it
* correct an incorrectly defined variable in a test
* make sure relative links in link block return alias locale URLs even when alias Locale does not exist in the database
* add an indicator for alias locales on the locale list page in Wagtail
* make sure root pages in new Locales are properly created
this fixes an error where translating a page into
the new Locales was causing a server error,
because wagtail-localize was not able to correctly
find the root page in the new Locale.
* make sure page links correctly point to page URLs in other locales
* add column filters in the wagtail localize dashboard
* use latest version of wagtail-localize-dashboard
* make sure canonical and alternate hreflangs are valid
do not show hreflang alternates for alias locales
that don't have their own content
* add template file used in test
* avoid leaking test state by modifying jinja2_loader.searchpath, rather than setting template engines
* make sure new root pages are created at the correct depth
* make sure we correctly render homepage content for alias locales
* make logic more readable by separating middleware and URL-routing logic
The separation:
- makes the logic more readable
- avoids a scenario where the middleware intercepts
the request and returns a Wagtail page when it
should not
* reorder migrations after merge
* make sure redirects based on Accept-Language header work for non-depth-2 home page sites
Previously, the middleware's Accept-Language
redirect was hardcoding Wagtail url_path prefixes
as /home and /home-{locale}, which only works when
the site root page is at depth 2. In environments
where Site.root_page is at a different depth (for
example at depth 3 with url_path=/home/home/), the
hardcoded prefixes were not matching pages,
causing 404s instead of redirects for Wagtail
Locales that did not have a specific page.
* reorder migrations after merge
* fix minor typos in tests
* add unit tests for different root page scenarios in fallback locale
* disable creating alias locale records in db export script
* update comment in migration to be accurate based on middleware refactoring
* make code more readable by referring to request interception in a consistent way
* make code more readable by moving fallback locale check into helper function
* add explicit test that a live Page in an alias locale is served as expected
* be more specific about the exception when the site root does not exist in a fallback locale
* be more efficient when calculating existing locales
* be more specific about the exceptions raised in SpringfieldLinkBlockURLValue.get_url()
* Remove extra whitespace in comment
Co-authored-by: Steve Jalim <stevejalim@mozilla.com>
* get locale directly from the URL, rather than an attribute on the request
This change makes the code less likely to break
in case any changes are made to our code that
sets the 'locale' attribute on the request
* update 'compare' and 'more' URLs to use prefer_cms()
* add helper functions for FTL parsing
* add a field to determine if article detail siblings should be visible on article index page
* add a management command to create 'compare' and 'more' CMS pages
* add migrations to create 'compare' and 'more' pages
* reorder migrations after merge
* reorder migrations after merge
* explicitly set show_sibling_detail_pages in test object
* update 'compare' and 'more' URLs to use prefer_cms()
* add helper functions for FTL parsing
* add a field to determine if article detail siblings should be visible on article index page
* add a management command to create 'compare' and 'more' CMS pages
* add migrations to create 'compare' and 'more' pages
* explicitly set show_sibling_detail_pages in test object
* reorder migrations to account for changes in main branch
* reorder migrations after merge
* reorder migrations after merge
* reorder migrations after merge
* [reset-db]
* [reset-db]
* add wagtailsearch migration dependency, to allow migration to run on fresh databases
* Organize imports on create compare pages command
* ArticleIndexPage supports 3 different card types
* update logic to create 'compare' and 'more' pages to set pages' index_card_type
* merge migration
* updated migration list
---------
Co-authored-by: Steve Jalim <stevejalim@mozilla.com>
Co-authored-by: Kasey Kelly <kasey@servee.com>
Co-authored-by: Mariana Bedran Lesche <maribedran@gmail.com>1 parent a3c90de commit 167f4e1
11 files changed
Lines changed: 1841 additions & 106 deletions
File tree
- springfield
- cms
- fixtures
- management/commands
- migrations
- models
- templates/cms
- tests
- firefox
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
26 | 41 | | |
| 42 | + | |
27 | 43 | | |
28 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
29 | 80 | | |
30 | 81 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
35 | 91 | | |
36 | 92 | | |
| 93 | + | |
| 94 | + | |
37 | 95 | | |
| 96 | + | |
38 | 97 | | |
| 98 | + | |
39 | 99 | | |
40 | | - | |
41 | | - | |
42 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
43 | 119 | | |
44 | 120 | | |
45 | 121 | | |
| |||
195 | 271 | | |
196 | 272 | | |
197 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
198 | 304 | | |
199 | 305 | | |
200 | 306 | | |
| |||
362 | 468 | | |
363 | 469 | | |
364 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
365 | 513 | | |
366 | 514 | | |
367 | 515 | | |
| |||
0 commit comments