diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 09d5284361704fc7cabb834d5c396f29df538b9d..c9936abd6cb792a8cb7796b6c90a6ba1f433f599 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -103,6 +103,7 @@ class Communication::Website::Page < ApplicationRecord end def references + [parent] + menu_items end diff --git a/app/models/communication/website/with_special_pages.rb b/app/models/communication/website/with_special_pages.rb index 52e36e59acb75057090a8f3075b7d6672d384986..909be747f32697568cb973097a8ce58a2fe0f46c 100644 --- a/app/models/communication/website/with_special_pages.rb +++ b/app/models/communication/website/with_special_pages.rb @@ -28,6 +28,12 @@ module Communication::Website::WithSpecialPages def translate_special_page(type, language) # Not found for given language, we create it from the page in default_language original_special_page = pages.where(type: type.to_s, language_id: default_language_id).first - original_special_page.translate!(language) if original_special_page.present? + return unless original_special_page.present? + translated_special_page = original_special_page.translate!(language) + # When we translate a new post, it will generate the permalink by looking for the posts special page + # It will try to find it, or translate it if not found + # At this moment, we need to sync the page with git (in case it's already published) + translated_special_page.sync_with_git + translated_special_page end end