Permalink
Browse files

Merge pull request #5 from fulv/ticket11189

Ticket11189
  • Loading branch information...
2 parents d5459fb + 44c8434 commit 251fb240766d679b39d9d249f22a5b49ea3b27e1 @garbas garbas committed Nov 21, 2011
View
12 Products/CMFPlone/browser/navigation.py
@@ -150,6 +150,9 @@ def _getNavQuery(self):
def topLevelTabs(self, actions=None, category='portal_tabs'):
context = aq_inner(self.context)
+ mtool = getToolByName(context, 'portal_membership')
+ member = mtool.getAuthenticatedMember().id
+
portal_properties = getToolByName(context, 'portal_properties')
self.navtree_properties = getattr(portal_properties,
'navtree_properties')
@@ -179,11 +182,18 @@ def topLevelTabs(self, actions=None, category='portal_tabs'):
rawresult = self.portal_catalog.searchResults(query)
+ def get_link_url(item):
+ linkremote = item.getRemoteUrl and not member == item.Creator
+ if linkremote:
+ return (get_id(item), item.getRemoteUrl)
+ else:
+ return False
+
# now add the content to results
idsNotToList = self.navtree_properties.getProperty('idsNotToList', ())
for item in rawresult:
if not (item.getId in idsNotToList or item.exclude_from_nav):
- id, item_url = get_view_url(item)
+ id, item_url = get_link_url(item) or get_view_url(item)
data = {'name': utils.pretty_title_or_id(context, item),
'id': item.getId,
'url': item_url,
View
7 Products/CMFPlone/browser/navtree.py
@@ -150,6 +150,12 @@ def decoratorFactory(self, node):
if portalType is not None and portalType in self.viewActionTypes:
itemUrl += '/view'
+ useRemoteUrl = False
+ getRemoteUrl = getattr(item, 'getRemoteUrl', None)
+ isCreator = self.memberId == getattr(item, 'Creator', None)
+ if getRemoteUrl and not isCreator:
+ useRemoteUrl = True
+
isFolderish = getattr(item, 'is_folderish', None)
showChildren = False
if isFolderish and (portalType is None or portalType not in self.parentTypesNQ):
@@ -173,6 +179,7 @@ def decoratorFactory(self, node):
newNode['no_display'] = False # We sort this out with the nodeFilter
# BBB getRemoteUrl and link_remote are deprecated, remove in Plone 4
newNode['getRemoteUrl'] = getattr(item, 'getRemoteUrl', None)
+ newNode['useRemoteUrl'] = useRemoteUrl
newNode['link_remote'] = newNode['getRemoteUrl'] and newNode['Creator'] != self.memberId
idnormalizer = queryUtility(IIDNormalizer)
View
21 Products/CMFPlone/tests/testNavigationView.py
@@ -664,6 +664,27 @@ def testPortalTabsNotIncludeViewNamesInCSSid(self):
for tab in tabs:
self.assertEqual(validateCSSIdentifier(tab['id']),True)
+ def testLinkRemoteUrlsUsedUnlessLinkCreator(self):
+ self.setRoles(['Manager'])
+ self.portal.invokeFactory('Link', 'link1')
+ self.portal.link1.setRemoteUrl('http://plone.org')
+ self.portal.link1.reindexObject()
+ view = self.view_class(self.portal, self.request)
+ tabs = view.topLevelTabs(actions=[])
+ for tab in tabs:
+ # as Creator tab for link1 should have url of the item
+ if tab['id'] == 'link1':
+ self.failUnless(tab['url'] == 'http://nohost/plone/link1')
+
+ self.setRoles(['Manager'])
+ self.portal.link1.setCreators(['some_other_user'])
+ self.portal.link1.reindexObject()
+ tabs = view.topLevelTabs(actions=[])
+ for tab in tabs:
+ # as non-Creator user, tab for link1 should have url of the remote url
+ if tab['id'] == 'link1':
+ self.failUnless(tab['url'] == 'http://plone.org')
+
class TestCatalogPortalTabs(TestBasePortalTabs):
view_class = CatalogNavigationTabs
View
3 docs/CHANGES.txt
@@ -7,6 +7,9 @@ Changelog
4.2b1 - Unreleased
------------------
+- Fixed the two high priority scenarios (global sections viewlet and nav
+ portlet) of http://dev.plone.org/ticket/11189.
+ [fulv]
- Call the view to unlock an item on unload synchronously, so that the
call succeeds on Webkit browsers. This closes

0 comments on commit 251fb24

Please sign in to comment.