diff --git a/news/475.breaking b/news/475.breaking new file mode 100644 index 000000000..d5345a2d6 --- /dev/null +++ b/news/475.breaking @@ -0,0 +1,4 @@ +Plone Site is now a DX container. This means that the front-page object no +longer exists. +Refs PLIP 2454. +[jaroel] diff --git a/plone/app/contenttypes/setuphandlers.py b/plone/app/contenttypes/setuphandlers.py index 80e812285..1ced30115 100644 --- a/plone/app/contenttypes/setuphandlers.py +++ b/plone/app/contenttypes/setuphandlers.py @@ -154,51 +154,42 @@ def _setup_constrains(container, allowed_types): def create_frontpage(portal, target_language): - frontpage_id = 'front-page' - - if frontpage_id not in portal.keys(): - title = _translate( - u'front-title', - target_language, - u'Welcome to Plone' - ) - description = _translate( - u'front-description', target_language, - u'Congratulations! You have successfully installed Plone.' - ) - content = createContent( - 'Document', id=frontpage_id, - title=title, - description=description, - language=target_language.replace('_', '-').lower()) - content = addContentToContainer(portal, content) - front_text = None - if target_language != 'en': - util = queryUtility(ITranslationDomain, 'plonefrontpage') - if util is not None: - translated_text = util.translate( - u'front-text', - target_language=target_language - ) - if translated_text != u'front-text': - front_text = translated_text - request = getattr(portal, 'REQUEST', None) - if front_text is None and request is not None: - view = queryMultiAdapter( - (portal, request), - name='plone-frontpage-setup' + if portal.text: + # Do not overwrite existing content + return + portal.title = _translate( + u'front-title', + target_language, + u'Welcome to Plone' + ) + portal.description = _translate( + u'front-description', target_language, + u'Congratulations! You have successfully installed Plone.' + ) + front_text = None + if target_language != 'en': + util = queryUtility(ITranslationDomain, 'plonefrontpage') + if util is not None: + translated_text = util.translate( + u'front-text', + target_language=target_language ) - if view is not None: - front_text = bodyfinder(view.index()).strip() - content.text = RichTextValue( - front_text, - 'text/html', - 'text/x-html-safe' + if translated_text != u'front-text': + front_text = translated_text + request = getattr(portal, 'REQUEST', None) + if front_text is None and request is not None: + view = queryMultiAdapter( + (portal, request), + name='plone-frontpage-setup' ) - - portal.setDefaultPage('front-page') - _publish(content) - content.reindexObject() + if view is not None: + front_text = bodyfinder(view.index()).strip() + portal.text = RichTextValue( + front_text, + 'text/html', + 'text/x-html-safe' + ) + portal.reindexObject() def create_news_topic(portal, target_language): diff --git a/plone/app/contenttypes/tests/test_content_profile.py b/plone/app/contenttypes/tests/test_content_profile.py index 86d33d066..b2f1c471a 100644 --- a/plone/app/contenttypes/tests/test_content_profile.py +++ b/plone/app/contenttypes/tests/test_content_profile.py @@ -49,22 +49,13 @@ def setUp(self): # front-page tests # # #################### # - def test_frontpage_was_created(self): - # Was the object created? - obj = self.portal['front-page'] - self.assertEqual(obj.portal_type, 'Document') - - def test_frontpage_is_default_page(self): - # Has the object been set on the container as the default page? - self.assertEqual(self.portal.default_page, 'front-page') - - def test_frontpage_is_published(self): - # Has the content object been published? - front_page = self.portal['front-page'] - current_state = self.portal_workflow.getInfoFor( - front_page, - 'review_state') - self.assertEqual(current_state, 'published') + def test_homepage(self): + self.assertEqual(self.portal.title, "Welcome to Plone") + self.assertEqual( + self.portal.description, + "Congratulations! You have successfully installed Plone." + ) + self.assertIn("Welcome!", self.portal.text.raw) # ################# # # Members tests #