diff --git a/docs/how-to/installation.md b/docs/how-to/installation.md index 48d5f4a4..0a32aece 100644 --- a/docs/how-to/installation.md +++ b/docs/how-to/installation.md @@ -54,6 +54,14 @@ class MyPage(Page): # ... ``` + +## Disabling default publication of tranlsated pages + +Live pages that are submitted for translation are made live immediately. If you wish pages to stay in draft form at that point, set `WAGTAILLOCALIZE_SYNC_LIVE_STATUS_ON_TRANSLATE = False` in your settings file. + + + + ## Control translation cleanup mode diff --git a/wagtail_localize/operations.py b/wagtail_localize/operations.py index ef77b4b9..a5c5dd4a 100644 --- a/wagtail_localize/operations.py +++ b/wagtail_localize/operations.py @@ -73,7 +73,11 @@ def create_translations(self, instance, include_related_objects=True): self.mappings[source].append(translation) # Determine whether or not to publish the translation. - publish = getattr(instance, "live", True) + publish_on_translate_setting = getattr(settings, "WAGTAILLOCALIZE_SYNC_LIVE_STATUS_ON_TRANSLATE", True) + if publish_on_translate_setting == True: + publish = getattr(instance, "live", True) + else: + publish = False try: translation.save_target(user=self.user, publish=publish) diff --git a/wagtail_localize/tests/test_submit_translations.py b/wagtail_localize/tests/test_submit_translations.py index 981bce88..c07a431b 100644 --- a/wagtail_localize/tests/test_submit_translations.py +++ b/wagtail_localize/tests/test_submit_translations.py @@ -246,6 +246,25 @@ def test_post_submit_page_translation(self): response, reverse("wagtailadmin_pages:edit", args=[translated_page.id]) ) + @override_settings(WAGTAILLOCALIZE_SYNC_LIVE_STATUS_ON_TRANSLATE=False) + def test_post_submit_page_translation_draft(self): + response = self.client.post( + reverse( + "wagtail_localize:submit_page_translation", + args=[self.en_blog_index.id], + ), + {"locales": [self.fr_locale.id]}, + ) + + translation = Translation.objects.get() + self.assertEqual(translation.source.locale, self.en_locale) + self.assertEqual(translation.target_locale, self.fr_locale) + self.assertTrue(translation.created_at) + + # The translated page should've been created and published + translated_page = self.en_blog_index.get_translation(self.fr_locale) + self.assertFalse(translated_page.live) + def test_post_submit_page_translation_submits_linked_snippets(self): self.en_blog_index.test_snippet = TestSnippet.objects.create( field="My test snippet"