-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide a hybrid list of locales drawn from CMS-backed and Django-bac…
…ked sources (#15475) * Refactor the logic for enumerating available locales for a CMS page ...so that we can use it independently of AbstractBedrockCMSPage._patch_request_for_bedrock() in the enhancement to follow * Ensure get_locales_for_cms_page ignores draft pages * Set correct lang-picker options when different locales for a given path may be served by the CMS or the Django fallback view * Expand prefer_cms to take args that tell us what locales are available in the Django fallback version of the page * In prefer_cms annotate the request with lists of locales available in a CMS-backed version of the page and a Django-backed version * Add a new jinja helper to select the most appropriate list of locales to pass to the lang picker UI element * Add tests; drop support for using prefer_cms with the page() decorator Making it support a list of automatically-detected Fluent files would make the page() helper even busier, with little value: if we need to decorate a page() view with prefer_cms, we can refactor it to be a regular Django view and then decorate in the URLConf or on the view itself (Had to commit all in one go, alas, due to pre-commit constraints) * Add support for a dynamic callable of locales for a page This is to satisfy situations like the current VPN RC where overall it's available in 10 locales, but it's not consistently translated into all 10, so we can't claim that all pages are available in all of those locales in the picker. This approach makes the locale derivation pluggable * Use the new dynamic/callable approach to get locales with the _old_ VPN RC article page (The version with data exported from Contentful, ahead of us moving it all to Wagtail) * Update other parts of the codebase that may need to use the new lang-switcher code to cope with alt/fallback sources of locale info * Rename helper func for getting locales to be more generic * Update documentation for prefer_cms * Fix regression due to a bad rebase * Remove deprecated approach to passing in locale info * Expand test coverage, fix comments/feedback * Update import to be absolute not relative * Change DB-hitting list comprehension to be a subquery, for better performance
- Loading branch information
1 parent
30d8722
commit 42ea7e3
Showing
17 changed files
with
791 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.