# HG changeset patch # User Thierry Florac # Date 1466416779 -7200 # Node ID 349fd1600cf9d2d4369cd827f0e7a4a5db2c6aea # Parent 69a8e0ec55555e64cef49006951854e04c1b9972 Added interface for addings menu label diff -r 69a8e0ec5555 -r 349fd1600cf9 src/pyams_content/zmi/interfaces/__init__.py --- a/src/pyams_content/zmi/interfaces/__init__.py Thu Jun 02 15:32:09 2016 +0200 +++ b/src/pyams_content/zmi/interfaces/__init__.py Mon Jun 20 11:59:39 2016 +0200 @@ -19,8 +19,13 @@ from pyams_skin.interfaces.viewlet import IMenuItem # import packages +from zope.interface import Interface, Attribute +# +# Custom menus interfaces +# + class IDashboardMenu(IMenuItem): """Dashboard menu""" @@ -35,3 +40,13 @@ class ISummaryMenu(IMenuItem): """Summary menu""" + + +# +# Custom ZMI interfaces +# + +class IUserAddingsMenuLabel(Interface): + """Shared tool adding menu label""" + + label = Attribute("Addings menu label") diff -r 69a8e0ec5555 -r 349fd1600cf9 src/pyams_content/zmi/viewlet/toplinks/__init__.py --- a/src/pyams_content/zmi/viewlet/toplinks/__init__.py Thu Jun 02 15:32:09 2016 +0200 +++ b/src/pyams_content/zmi/viewlet/toplinks/__init__.py Mon Jun 20 11:59:39 2016 +0200 @@ -9,6 +9,7 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # +from pyams_content.zmi.interfaces import IUserAddingsMenuLabel __docformat__ = 'restructuredtext' @@ -32,6 +33,7 @@ from pyams_utils.registry import get_local_registry, get_utility from pyams_utils.url import absolute_url from pyams_viewlet.viewlet import viewlet_config +from pyramid.threadlocal import get_current_registry from pyams_content import _ @@ -49,7 +51,7 @@ registry = get_local_registry() for name, tool in registry.getUtilitiesFor(ISharedTool): menu = TopLinksMenu(self.context, self.request, self.__parent__, self) - menu.label = II18n(tool).query_attribute('short_name', request=self.request) or tool.__name__ + menu.label = II18n(tool).query_attribute('title', request=self.request) or tool.__name__ menu.url = absolute_url(tool, self.request, 'admin.html#dashboard.html') self.viewlets.append(menu) @@ -89,12 +91,17 @@ def update(self): super(UserAddingsMenu, self).update() catalog = get_utility(ICatalog) + registry = get_current_registry() params = And(Any(catalog['role:contributor'], {self.request.principal.id}), NotEq(catalog['content_type'], None)) for tool in sorted(unique(CatalogResultSet(CatalogQuery(catalog).query(params))), key=lambda x: II18n(x).query_attribute('title', request=self.request)): menu = TopLinksMenu(self.context, self.request, self.__parent__, self) - menu.label = self.request.localizer.translate(tool.shared_content_factory.content_class.content_name) + adapter = registry.queryMultiAdapter((tool, self.request), IUserAddingsMenuLabel) + if adapter is None: + menu.label = self.request.localizer.translate(tool.shared_content_factory.content_class.content_name) + else: + menu.label = adapter.label menu.url = absolute_url(tool, self.request, 'add-shared-content.html') menu.data = {'data-toggle': 'modal'} self.viewlets.append(menu)