Ejemplo n.º 1
0
    def testSelectedTabFolderishNavigationRoot2(self):
        self.loginAsPortalOwner()
        self.portal.invokeFactory('Folder',
                                  'testfolder',
                                  title='Test folder level 1')

        for i in range(2):
            self.portal.testfolder.invokeFactory('Folder',
                                                 'dummy1-{}'.format(i),
                                                 title='dummy folder')
        self.portal.testfolder.invokeFactory('Folder',
                                             'testfoldersecond',
                                             title='Test folder level 2')

        for i in range(2):
            self.portal.testfolder.invokeFactory('Folder',
                                                 'zummy1-{}'.format(i),
                                                 title='dummy folder')

        directlyProvides(self.portal.testfolder, INavigationRoot)
        self.app.REQUEST[
            'URL'] = self.portal.testfolder.testfoldersecond.absolute_url()
        viewlet = GlobalSectionsViewlet(
            self.portal.testfolder.testfoldersecond, self.app.REQUEST, None)
        viewlet.update()

        self.assertTrue(viewlet.selected_portal_tab ==
                        self.portal.testfolder.testfoldersecond.getId())
Ejemplo n.º 2
0
    def testSelectedTabFolderishNavigationRoot2(self):
        self.loginAsPortalOwner()
        self.portal.invokeFactory('Folder', 'testfolder',
                                  title='Test folder level 1')

        for i in range(2):
            self.portal.testfolder.invokeFactory(
                'Folder',
                'dummy1-{}'.format(i),
                title='dummy folder')
        self.portal.testfolder.invokeFactory(
            'Folder',
            'testfoldersecond',
            title='Test folder level 2')

        for i in range(2):
            self.portal.testfolder.invokeFactory(
                'Folder',
                'zummy1-{}'.format(i),
                title='dummy folder')

        directlyProvides(self.portal.testfolder, INavigationRoot)
        self.app.REQUEST['URL'] = self.portal.testfolder.testfoldersecond.absolute_url()
        viewlet = GlobalSectionsViewlet(
            self.portal.testfolder.testfoldersecond, self.app.REQUEST, None)
        viewlet.update()

        self.assertTrue(
            viewlet.selected_portal_tab == self.portal.testfolder.testfoldersecond.getId()
            )
Ejemplo n.º 3
0
    def testSelectedTabFolderish(self):
        self.app.REQUEST['URL'] = self.portal.news.absolute_url()
        viewlet = GlobalSectionsViewlet(self.portal.news, self.app.REQUEST,
                                        None)
        viewlet.update()

        self.assertTrue(
            viewlet.selected_portal_tab == self.portal.news.getId())
Ejemplo n.º 4
0
    def testSelectedTabFolderish(self):
        self.app.REQUEST['URL'] = self.portal.news.absolute_url()
        viewlet = GlobalSectionsViewlet(
            self.portal.news, self.app.REQUEST, None)
        viewlet.update()

        self.assertTrue(
            viewlet.selected_portal_tab == self.portal.news.getId()
            )
Ejemplo n.º 5
0
 def test_selectedtabs(self):
     """ Test selected tabs the simplest case
     """
     request = self.layer['request']
     request['URL'] = self.folder.absolute_url()
     gsv = GlobalSectionsViewlet(self.folder, request, None)
     gsv.update()
     self.assertEqual(gsv.selected_tabs, {'portal': 'Members'})
     self.assertEqual(gsv.selected_portal_tab, 'Members')
Ejemplo n.º 6
0
 def test_selectedtabs(self):
     """ Test selected tabs the simplest case
     """
     request = self.layer['request']
     request['URL'] = self.folder.absolute_url()
     gsv = GlobalSectionsViewlet(self.folder, request, None)
     gsv.update()
     self.assertEqual(gsv.selected_tabs, {'portal': 'Members'})
     self.assertEqual(gsv.selected_portal_tab, 'Members')
Ejemplo n.º 7
0
    def update(self):
        GlobalSectionsViewlet.update(self)
        self.context_state = getMultiAdapter((self.context, self.request), name=u"plone_context_state")
        self.current_url = self.context_state.current_base_url()

        for tab in self.portal_tabs:
            if tab["id"] != "Members":
                tab["subtab"] = self.getsubtab(self.context, tab)
            else:
                tab["subtab"] = []
Ejemplo n.º 8
0
    def testSelectedTabNotFolderish(self):
        self.loginAsPortalOwner()
        self.portal.invokeFactory('Document', 'testdocument',
                                  title='Test document')
        self.app.REQUEST['URL'] = self.portal.testdocument.absolute_url()
        viewlet = GlobalSectionsViewlet(
            self.portal.testdocument, self.app.REQUEST, None)
        viewlet.update()

        self.assertTrue(
            viewlet.selected_portal_tab == self.portal.testdocument.getId()
            )
Ejemplo n.º 9
0
    def testSelectedTabImage(self):
        self.loginAsPortalOwner()
        self.portal.invokeFactory('Image', 'testimage', title='Test image')
        self.portal.testimage.setImage(StringIO(SITE_LOGO_BASE64))
        self.portal.testimage.image = 1
        self.app.REQUEST['URL'] = self.portal.testimage.absolute_url()
        viewlet = GlobalSectionsViewlet(self.portal.testimage,
                                        self.app.REQUEST, None)
        viewlet.update()

        self.assertTrue(
            viewlet.selected_portal_tab == self.portal.testimage.getId())
Ejemplo n.º 10
0
    def testSelectedTabNotFolderish(self):
        self.loginAsPortalOwner()
        self.portal.invokeFactory('Document',
                                  'testdocument',
                                  title='Test document')
        self.app.REQUEST['URL'] = self.portal.testdocument.absolute_url()
        viewlet = GlobalSectionsViewlet(self.portal.testdocument,
                                        self.app.REQUEST, None)
        viewlet.update()

        self.assertTrue(
            viewlet.selected_portal_tab == self.portal.testdocument.getId())
Ejemplo n.º 11
0
    def update(self):
        GlobalSectionsViewlet.update(self)
        self.portal_registry = component.getUtility(IRegistry)

        key = "plonetheme.jquerymobile.viewlet.globalsections.filter"
        self.data_filter_reveal = "false"
        if self.portal_registry.get(key, False):
            self.data_filter_reveal = "true"

        key = "plonetheme.jquerymobile.viewlet.globalsections.filterreveal"
        self.data_filter = "false"
        if self.portal_registry.get(key, False):
            self.data_filter = "true"
Ejemplo n.º 12
0
    def testSelectedTabImage(self):
        self.loginAsPortalOwner()
        self.portal.invokeFactory('Image', 'testimage',
                                  title='Test image')
        self.portal.testimage.setImage(StringIO(SITE_LOGO_BASE64))
        self.portal.testimage.image = 1
        self.app.REQUEST['URL'] = self.portal.testimage.absolute_url()
        viewlet = GlobalSectionsViewlet(
            self.portal.testimage, self.app.REQUEST, None)
        viewlet.update()

        self.assertTrue(
            viewlet.selected_portal_tab == self.portal.testimage.getId()
            )
Ejemplo n.º 13
0
 def test_globalnav_respects_types_use_view_action_in_listings(self):
     """ Test selected tabs with a INavigationroot folder involved
     """
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     self.portal.invokeFactory('Image', 'image', title=u'Söme Image')
     self.portal.invokeFactory('File', 'file', title=u'Some File')
     self.portal.invokeFactory('Document', 'doc', title=u'Some Döcument')
     request = self.layer['request']
     gsv = GlobalSectionsViewlet(self.portal, request, None)
     gsv.update()
     html = gsv.render()
     self.assertIn('href="http://nohost/plone/image/view"', html)
     self.assertIn('href="http://nohost/plone/file/view"', html)
     self.assertIn('href="http://nohost/plone/doc"', html)
Ejemplo n.º 14
0
 def test_globalnav_respects_types_use_view_action_in_listings(self):
     """ Test selected tabs with a INavigationroot folder involved
     """
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     self.portal.invokeFactory('Image', 'image', title=u'Söme Image')
     self.portal.invokeFactory('File', 'file', title=u'Some File')
     self.portal.invokeFactory('Document', 'doc', title=u'Some Döcument')
     request = self.layer['request']
     gsv = GlobalSectionsViewlet(self.portal, request, None)
     gsv.update()
     html = gsv.render()
     self.assertIn('href="http://nohost/plone/image/view"', html)
     self.assertIn('href="http://nohost/plone/file/view"', html)
     self.assertIn('href="http://nohost/plone/doc"', html)
Ejemplo n.º 15
0
    def test_link_redirect_view(self):
        portal_url = self.portal['portal_url']()
        link_1_url = self.link_1.restrictedTraverse(
            '@@link_redirect_view', ).absolute_target_url()
        self.assertEqual(
            '{0}/assuntos/editoria-a'.format(portal_url),
            link_1_url,
        )
        link_2_url = self.link_2.restrictedTraverse(
            '@@link_redirect_view', ).absolute_target_url()
        self.assertEqual(
            '{0}/assuntos/editoria-b'.format(portal_url),
            link_2_url,
        )
        link_3_url = self.link_3.restrictedTraverse(
            '@@link_redirect_view', ).absolute_target_url()
        self.assertEqual(
            '{0}/assuntos/editoria-c'.format(portal_url),
            link_3_url,
        )
        link_4_url = self.link_4.restrictedTraverse(
            '@@link_redirect_view', ).absolute_target_url()
        self.assertEqual(
            '{0}/folder/subfolder'.format(portal_url),
            link_4_url,
        )
        link_5_url = self.link_5.restrictedTraverse(
            '@@link_redirect_view', ).absolute_target_url()
        self.assertEqual(
            '{0}/en/subjects/editorial'.format(portal_url),
            link_5_url,
        )

        portal_properties = api.portal.get_tool('portal_properties')
        navtree_properties = portal_properties.navtree_properties
        metaTypesNotToList = list(
            navtree_properties.getProperty('metaTypesNotToList'))
        metaTypesNotToList.remove('Link')
        navtree_properties.manage_changeProperties(
            metaTypesNotToList=metaTypesNotToList)

        logout()
        viewlet = GlobalSectionsViewlet(self.portal, self.request, None, None)
        viewlet.update()
        html = viewlet.render()

        self.assertIn('href="http://nohost/plone/en/subjects/languages"', html)
        self.assertNotIn('href="/plone/en/subjects/languages"', html)
Ejemplo n.º 16
0
 def test_selectedtabs_navroot(self):
     """ Test selected tabs with a INavigationroot folder involved
     """
     self.setRoles(('Manager', ))
     self.portal.invokeFactory('Folder', 'navroot', title='My new root')
     navroot = self.portal['navroot']
     alsoProvides(navroot, INavigationRoot)
     navroot.invokeFactory('Folder', 'abc', title='short')
     navroot.invokeFactory('Folder',
                           'xyz',
                           title='Folder with a looong name')
     request = self.layer['request']
     request['URL'] = navroot['abc'].absolute_url()
     gsv = GlobalSectionsViewlet(navroot, request, None)
     gsv.update()
     self.assertEqual(gsv.selected_tabs, {'portal': 'abc'})
     self.assertEqual(gsv.selected_portal_tab, 'abc')
Ejemplo n.º 17
0
 def test_selectedtabs_navroot(self):
     """ Test selected tabs with a INavigationroot folder involved
     """
     self.setRoles(('Manager',))
     self.portal.invokeFactory('Folder', 'navroot', title='My new root')
     navroot = self.portal['navroot']
     alsoProvides(navroot, INavigationRoot)
     navroot.invokeFactory('Folder', 'abc', title='short')
     navroot.invokeFactory('Folder',
                           'xyz',
                           title='Folder with a looong name')
     request = self.layer['request']
     request['URL'] = navroot['abc'].absolute_url()
     gsv = GlobalSectionsViewlet(navroot, request, None)
     gsv.update()
     self.assertEqual(gsv.selected_tabs, {'portal': 'abc'})
     self.assertEqual(gsv.selected_portal_tab, 'abc')
Ejemplo n.º 18
0
    def get_main_links(self):
        viewlet = GlobalSectionsViewlet(self.context, self.request, None)
        viewlet.update()
        selected_tab = viewlet.selected_portal_tab

        site = api.portal.get()
        site_default_page = getDefaultPage(site)
        if selected_tab == site_default_page:
            selected_tab = 'index_html'

        default_page_url = '{}/{}'.format(site.absolute_url(),
                                          site_default_page)
        tabs = []
        for tab in viewlet.portal_tabs:
            if tab['url'] == default_page_url:
                continue
            tabs.append(tab)

        return {'selected_portal_tab': selected_tab, 'portal_tabs': tabs}
Ejemplo n.º 19
0
    def test_globalnav_navigation_depth(self):
        """ Test selected tabs with a INavigationroot folder involved
        """
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        registry = getUtility(IRegistry)
        registry['plone.navigation_depth'] = 3
        self.portal.invokeFactory('Folder', 'folder', title=u'Földer')
        self.portal.invokeFactory('Folder', 'folder2', title=u'Folder 2')
        self.portal.invokeFactory('Folder', 'folder3', title=u'Folder 3')
        folder = self.portal.folder
        folder.invokeFactory('Folder', 'subfolder', title=u'Subfolder')
        folder.invokeFactory('Folder', 'subfolder2', title=u'Sübfolder 2')
        subfolder = folder.subfolder
        subfolder.invokeFactory('Folder', 'subsubfolder', title=u'Sub2folder')

        request = self.layer['request']
        navtree = self._get_navtree()
        self.assertListEqual(
            sorted(navtree),
            [
                '/plone',
                '/plone/Members',
                '/plone/folder',
                '/plone/folder/subfolder'
            ],
        )
        self.assertListEqual(
            [x['title'] for x in navtree['/plone']],
            [u'Home', u'Members', u'Földer', u'Folder 2', u'Folder 3'],
        )
        self.assertListEqual(
            [x['title'] for x in navtree['/plone/folder']],
            [u'Subfolder', u'Sübfolder 2'],
        )
        self.assertListEqual(
            [x['title'] for x in navtree['/plone/folder/subfolder']],
            [u'Sub2folder'],
        )

        gsv = GlobalSectionsViewlet(self.portal, request, None)
        gsv.update()
        self.assertTrue(gsv.render())
Ejemplo n.º 20
0
    def test_globalnav_navigation_depth(self):
        """ Test selected tabs with a INavigationroot folder involved
        """
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        registry = getUtility(IRegistry)
        registry['plone.navigation_depth'] = 3
        self.portal.invokeFactory('Folder', 'folder', title=u'Földer')
        self.portal.invokeFactory('Folder', 'folder2', title=u'Folder 2')
        self.portal.invokeFactory('Folder', 'folder3', title=u'Folder 3')
        folder = self.portal.folder
        folder.invokeFactory('Folder', 'subfolder', title=u'Subfolder')
        folder.invokeFactory('Folder', 'subfolder2', title=u'Sübfolder 2')
        subfolder = folder.subfolder
        subfolder.invokeFactory('Folder', 'subsubfolder', title=u'Sub2folder')

        request = self.layer['request']
        navtree = self._get_navtree()
        self.assertListEqual(
            sorted(navtree),
            [
                '/plone', '/plone/Members', '/plone/folder',
                '/plone/folder/subfolder'
            ],
        )
        self.assertListEqual(
            [x['title'] for x in navtree['/plone']],
            [u'Home', u'Members', u'Földer', u'Folder 2', u'Folder 3'],
        )
        self.assertListEqual(
            [x['title'] for x in navtree['/plone/folder']],
            [u'Subfolder', u'Sübfolder 2'],
        )
        self.assertListEqual(
            [x['title'] for x in navtree['/plone/folder/subfolder']],
            [u'Sub2folder'],
        )

        gsv = GlobalSectionsViewlet(self.portal, request, None)
        gsv.update()
        self.assertTrue(gsv.render())
Ejemplo n.º 21
0
 def _get_navtree(self, context=None):
     if context is None:
         context = self.portal
     gsv = GlobalSectionsViewlet(context, self.request.clone(), None)
     return gsv.navtree