Added attribute to shared contents managers to separate menus between shared contents and shared tools
--- a/src/pyams_content/shared/common/interfaces/__init__.py Thu Apr 12 17:45:09 2018 +0200
+++ b/src/pyams_content/shared/common/interfaces/__init__.py Thu Apr 12 18:26:22 2018 +0200
@@ -84,6 +84,9 @@
containers(ISharedToolContainer)
+ shared_content_menu = Attribute("Boolean flag indicating if tool is displayed into 'Shared contents' or "
+ "Shared tools' menu")
+
shared_content_workflow = Choice(title=_("Workflow name"),
description=_("Name of workflow utility used to manage tool contents"),
vocabulary="PyAMS workflows",
--- a/src/pyams_content/shared/common/manager.py Thu Apr 12 17:45:09 2018 +0200
+++ b/src/pyams_content/shared/common/manager.py Thu Apr 12 18:26:22 2018 +0200
@@ -58,6 +58,7 @@
title = FieldProperty(IBaseSharedTool['title'])
short_name = FieldProperty(IBaseSharedTool['short_name'])
+ shared_content_menu = True
shared_content_workflow = FieldProperty(IBaseSharedTool['shared_content_workflow'])
--- a/src/pyams_content/shared/form/manager.py Thu Apr 12 17:45:09 2018 +0200
+++ b/src/pyams_content/shared/form/manager.py Thu Apr 12 18:26:22 2018 +0200
@@ -37,6 +37,7 @@
"""Forms manager class"""
shared_content_type = FORM_CONTENT_TYPE
+ shared_content_menu = False
@utility_config(provides=IFormsManagerFactory)
--- a/src/pyams_content/shared/imagemap/manager.py Thu Apr 12 17:45:09 2018 +0200
+++ b/src/pyams_content/shared/imagemap/manager.py Thu Apr 12 18:26:22 2018 +0200
@@ -37,6 +37,7 @@
"""Image maps manager class"""
shared_content_type = IMAGEMAP_CONTENT_TYPE
+ shared_content_menu = False
@utility_config(provides=IImageMapManagerFactory)
--- a/src/pyams_content/shared/logo/manager.py Thu Apr 12 17:45:09 2018 +0200
+++ b/src/pyams_content/shared/logo/manager.py Thu Apr 12 18:26:22 2018 +0200
@@ -37,6 +37,7 @@
"""Logos manager class"""
shared_content_type = LOGO_CONTENT_TYPE
+ shared_content_menu = False
@utility_config(provides=ILogosManagerFactory)
--- a/src/pyams_content/shared/view/manager.py Thu Apr 12 17:45:09 2018 +0200
+++ b/src/pyams_content/shared/view/manager.py Thu Apr 12 18:26:22 2018 +0200
@@ -38,6 +38,7 @@
"""Views manager class"""
shared_content_type = VIEW_CONTENT_TYPE
+ shared_content_menu = False
@utility_config(provides=IViewsManagerFactory)
--- a/src/pyams_content/skin/zmi/viewlet/toplinks/__init__.py Thu Apr 12 17:45:09 2018 +0200
+++ b/src/pyams_content/skin/zmi/viewlet/toplinks/__init__.py Thu Apr 12 18:26:22 2018 +0200
@@ -57,20 +57,41 @@
self.viewlets.append(menu)
-@viewlet_config(name='shared-tools.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=30)
-class SharedToolsMenu(TopLinksViewlet):
- """Shared tools menu"""
+@viewlet_config(name='shared-contents.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=30)
+class SharedContentsMenu(TopLinksViewlet):
+ """Shared contents menu"""
label = ''
css_class = 'top-menu bordered margin-top-10'
dropdown_label = _("Shared contents")
def update(self):
+ super(SharedContentsMenu, self).update()
+ registry = get_local_registry()
+ for tool in sorted(registry.getAllUtilitiesRegisteredFor(IBaseSharedTool),
+ key=lambda x: II18n(x).query_attribute('title', request=self.request) or ''):
+ if ISharedSite.providedBy(tool) or (not tool.shared_content_menu):
+ continue
+ menu = TopLinksMenu(self.context, self.request, self.__parent__, self)
+ menu.label = II18n(tool).query_attribute('title', request=self.request) or tool.__name__
+ menu.url = absolute_url(tool, self.request, 'admin#dashboard.html')
+ self.viewlets.append(menu)
+
+
+@viewlet_config(name='shared-tools.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=40)
+class SharedToolsMenu(TopLinksViewlet):
+ """Shared tools menu"""
+
+ label = ''
+ css_class = 'top-menu bordered margin-top-10'
+ dropdown_label = _("Shared tools")
+
+ def update(self):
super(SharedToolsMenu, self).update()
registry = get_local_registry()
for tool in sorted(registry.getAllUtilitiesRegisteredFor(IBaseSharedTool),
key=lambda x: II18n(x).query_attribute('title', request=self.request) or ''):
- if ISharedSite.providedBy(tool):
+ if ISharedSite.providedBy(tool) or tool.shared_content_menu:
continue
menu = TopLinksMenu(self.context, self.request, self.__parent__, self)
menu.label = II18n(tool).query_attribute('title', request=self.request) or tool.__name__