Added shared sites menu
authorThierry Florac <thierry.florac@onf.fr>
Mon, 20 Jun 2016 12:27:04 +0200
changeset 45 74b7fbb59a92
parent 44 6931ae3912c9
child 46 54e9500c3a00
Added shared sites menu
src/pyams_content/zmi/viewlet/toplinks/__init__.py
--- a/src/pyams_content/zmi/viewlet/toplinks/__init__.py	Mon Jun 20 12:26:37 2016 +0200
+++ b/src/pyams_content/zmi/viewlet/toplinks/__init__.py	Mon Jun 20 12:27:04 2016 +0200
@@ -9,7 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from pyams_content.zmi.interfaces import IUserAddingsMenuLabel
 
 __docformat__ = 'restructuredtext'
 
@@ -18,7 +17,8 @@
 
 # import interfaces
 from hypatia.interfaces import ICatalog
-from pyams_content.shared.common.interfaces import ISharedTool
+from pyams_content.shared.common.interfaces import ISharedTool, ISharedSite
+from pyams_content.zmi.interfaces import IUserAddingsMenuLabel
 from pyams_i18n.interfaces import II18n
 from pyams_skin.interfaces.viewlet import ITopLinksViewletManager
 from pyams_zmi.layer import IAdminLayer
@@ -38,6 +38,24 @@
 from pyams_content import _
 
 
+@viewlet_config(name='shared-sites.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=20)
+class SharedSitesMenu(TopLinksViewlet):
+    """Shared sites menu"""
+
+    label = ''
+    css_class = 'top-menu bordered margin-top-10'
+    dropdown_label = _("Shared sites")
+
+    def update(self):
+        super(SharedSitesMenu, self).update()
+        registry = get_local_registry()
+        for name, site in registry.getUtilitiesFor(ISharedSite):
+            menu = TopLinksMenu(self.context, self.request, self.__parent__, self)
+            menu.label = II18n(site).query_attribute('title', request=self.request) or tool.__name__
+            menu.url = absolute_url(site, self.request, 'admin.html#dashboard.html')
+            self.viewlets.append(menu)
+
+
 @viewlet_config(name='shared-tools.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=30)
 class SharedToolsMenu(TopLinksViewlet):
     """Shared tools menu"""
@@ -50,6 +68,8 @@
         super(SharedToolsMenu, self).update()
         registry = get_local_registry()
         for name, tool in registry.getUtilitiesFor(ISharedTool):
+            if ISharedSite.providedBy(tool):
+                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.html#dashboard.html')