Use a consistent parenting strategy for page translations #3564
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.
Fixes #3533
I believe these these two tests represent incompatible notions of page parent relationships:
spotlight/spec/models/spotlight/page_spec.rb
Lines 243 to 247 in e48b227
spotlight/spec/models/spotlight/page_spec.rb
Lines 297 to 300 in e48b227
The first test suggests that a translated child page can and should point its
parent_pageat the default locale parent page when there is no translated parent page available.The second test suggests that translated children should have a
nilparent relationship when the translated parent is missing.I think this all might be somewhat awkwardly modeled, but
nilparent relationships make more sense for our existing code.This bug was caused by a discrepancy with the parent handling between:
spotlight/app/models/spotlight/page.rb
Lines 154 to 167 in e48b227
and:
spotlight/app/models/spotlight/page.rb
Lines 171 to 182 in e48b227
This PR would effectively mean you'd use locale to shift laterally between fully independent trees of feature pages
Checking if you have translated pages that would be impacted
In a Rails console in your Spotlight app:
If you have impacted pages (
pages_with_the_bug.length > 0) you have two choices:pages_with_the_bugpagesparent_pagerelationship tonilfor allpages_with_the_bugpagesPotential Future Work
This PR only serves to establish consistency in how we treat page parent relationships, it does not address the somewhat odd behavior than can arise from how they are currently modeled. Take this example, where all pages with the exception of

FP 3have French translations:When viewing the exhibit in French the ordering can differ significantly from the default locale because of the mismatch between the page trees and the weights being considered.

The Spotlight community may want to revisit if this current page translation approach is meeting their needs or if moving to a more simple approach would suffice.