예제 #1
0
    def test_languages_untranslated_by_closest(self):
        # Define selector policy
        self.registry = getUtility(IRegistry)
        self.settings = self.registry.forInterface(IMultiLanguagePolicies)
        self.settings.selector_lookup_translations_policy = 'closest'

        wftool = getToolByName(self.portal, "portal_workflow")

        a_ca = createContentInContainer(
            self.portal['ca'], 'Document', title=u"Test document")
        a_ca.setLanguage('ca')
        wftool.doActionFor(a_ca, 'publish')

        view = selector_view(a_ca, self.request)
        view.tg = ITG(a_ca)

        # Check that the 'original' language gets the created document
        view.lang = 'ca'
        url = view.getClosestDestination()
        self.assertEqual(url, a_ca.absolute_url())

        # Check that untranslated languages get the nearest translated parent
        view.lang = 'es'
        url = view.getClosestDestination()
        self.assertEqual(url, self.portal['es'].absolute_url())

        view.lang = 'en'
        url = view.getClosestDestination()
        self.assertEqual(url, self.portal['en'].absolute_url())

        # Check that translating content updates the closest destination
        a_es = api.translate(a_ca, 'es')
        view.lang = 'es'
        url = view.getClosestDestination()
        self.assertEqual(url, a_es.absolute_url())
예제 #2
0
    def test_languages_untranslated_by_closest(self):
        self.registry = getUtility(IRegistry)
        self.settings = self.registry.forInterface(IMultiLanguagePolicies)
        self.settings.selector_lookup_translations_policy = 'closest'
        self.setUpPAMFolders()

        document = makeContent(self.portal.ca, 'Document', id='untranslated')
        document.setLanguage('ca')
        wftool = getToolByName(self.portal, "portal_workflow")
        wftool.doActionFor(document, 'publish')
        transaction.commit()
        view = selector_view(document, self.layer['request'])
        view.lang = 'es'
        view.tg = ITG(document)
        url = view.getClosestDestination()
        self.assertEqual(url, self.portal.es.absolute_url())

        view.lang = 'it'
        url = view.getClosestDestination()
        self.assertEqual(url, self.portal.absolute_url())