Moved "pyams_content.zmi" package ro "pyams_content.skin.zmi"
authorThierry Florac <thierry.florac@onf.fr>
Fri, 26 Jan 2018 16:44:29 +0100
changeset 339 50c73e42883a
parent 338 f37b5995a48c
child 340 de5a2a9fdf22
Moved "pyams_content.zmi" package ro "pyams_content.skin.zmi"
src/pyams_content/skin/zmi/__init__.py
src/pyams_content/skin/zmi/interfaces/__init__.py
src/pyams_content/skin/zmi/tinymce.py
src/pyams_content/skin/zmi/viewlet/__init__.py
src/pyams_content/skin/zmi/viewlet/toplinks/__init__.py
src/pyams_content/skin/zmi/viewlet/toplinks/templates/user-addings.pt
src/pyams_content/zmi/tinymce.py
src/pyams_content/zmi/viewlet/__init__.py
src/pyams_content/zmi/viewlet/toplinks/__init__.py
src/pyams_content/zmi/viewlet/toplinks/templates/user-addings.pt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/skin/zmi/__init__.py	Fri Jan 26 16:44:29 2018 +0100
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+# import standard library
+
+# import interfaces
+
+# import packages
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/skin/zmi/interfaces/__init__.py	Fri Jan 26 16:44:29 2018 +0100
@@ -0,0 +1,56 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_skin.interfaces.viewlet import IMenuItem
+
+# import packages
+from zope.interface import Interface, Attribute
+
+
+#
+# Custom menus interfaces
+#
+
+class ISiteTreeMenu(IMenuItem):
+    """Site tree menu marker interface"""
+
+
+class ISiteTreeTable(Interface):
+    """Site tree table view marker interface"""
+
+
+class IDashboardMenu(IMenuItem):
+    """Dashboard menu"""
+
+
+class IMyDashboardMenu(IMenuItem):
+    """My contents dashboard menu"""
+
+
+class IAllContentsMenu(IMenuItem):
+    """Dashboard menu for all contents"""
+
+
+class ISummaryMenu(IMenuItem):
+    """Summary menu"""
+
+
+class IUserAddingsMenuLabel(Interface):
+    """Shared tool adding menu label"""
+
+    label = Attribute("Addings menu label")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/skin/zmi/tinymce.py	Fri Jan 26 16:44:29 2018 +0100
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_form.interfaces.form import IForm
+from pyams_skin.interfaces.tinymce import ITinyMCEConfiguration
+from pyams_skin.layer import IPyAMSLayer
+
+# import packages
+from pyams_utils.adapter import adapter_config, ContextRequestAdapter
+
+
+@adapter_config(context=(IForm, IPyAMSLayer), provides=ITinyMCEConfiguration)
+class TinyMCEEditorConfiguration(ContextRequestAdapter):
+    """TinyMCE editor configuration"""
+
+    @property
+    def configuration(self):
+        return {'ams-plugins': 'pyams_content',
+                'ams-plugin-pyams_content-src': '/--static--/pyams_content/js/pyams_content{MyAMS.devext}.js',
+                'ams-plugin-pyams_content-async': 'false',
+                'ams-tinymce-init-callback': 'PyAMS_content.TinyMCE.initEditor'}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/skin/zmi/viewlet/__init__.py	Fri Jan 26 16:44:29 2018 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+
+# import packages
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/skin/zmi/viewlet/toplinks/__init__.py	Fri Jan 26 16:44:29 2018 +0100
@@ -0,0 +1,129 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from hypatia.interfaces import ICatalog
+from pyams_content.shared.common.interfaces import IBaseSharedTool, ISharedSite
+from pyams_content.skin.zmi.interfaces import IUserAddingsMenuLabel
+from pyams_i18n.interfaces import II18n
+from pyams_skin.interfaces.viewlet import ITopLinksViewletManager
+from pyams_zmi.layer import IAdminLayer
+
+# import packages
+from hypatia.catalog import CatalogQuery
+from hypatia.query import Any, And, Or, NotEq
+from pyams_catalog.query import CatalogResultSet
+from pyams_skin.viewlet.toplinks import TopLinksViewlet, TopLinksMenu
+from pyams_template.template import template_config
+from pyams_utils.list import unique
+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 _
+
+
+@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 site in sorted(registry.getAllUtilitiesRegisteredFor(ISharedSite),
+                           key=lambda x: II18n(x).query_attribute('title', request=self.request) or ''):
+            menu = TopLinksMenu(self.context, self.request, self.__parent__, self)
+            menu.label = II18n(site).query_attribute('title', request=self.request) or site.__name__
+            menu.url = absolute_url(site, self.request, 'admin#dashboard.html')
+            self.viewlets.append(menu)
+
+
+@viewlet_config(name='shared-tools.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=30)
+class SharedToolsMenu(TopLinksViewlet):
+    """Shared tools menu"""
+
+    label = ''
+    css_class = 'top-menu bordered margin-top-10'
+    dropdown_label = _("Shared contents")
+
+    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):
+                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='user-roles.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=90)
+class UserRolesMenu(TopLinksViewlet):
+    """User roles menu"""
+
+    label = ''
+    css_class = 'top-menu bordered margin-top-10'
+    dropdown_label = _("My roles")
+
+    def update(self):
+        super(UserRolesMenu, self).update()
+        catalog = get_utility(ICatalog)
+        params = And(Or(Any(catalog['role:contributor'], {self.request.principal.id}),
+                        Any(catalog['role:manager'], {self.request.principal.id}),
+                        Any(catalog['role:pilot'], {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) or ''):
+            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='user-addings.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=95)
+@template_config(template='templates/user-addings.pt', layer=IAdminLayer)
+class UserAddingsMenu(TopLinksViewlet):
+    """User addings menu"""
+
+    label = ''
+    css_class = 'top-menu margin-top-5-neg'
+    dropdown_label = ''
+
+    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) or ''):
+            menu = TopLinksMenu(self.context, self.request, self.__parent__, self)
+            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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/skin/zmi/viewlet/toplinks/templates/user-addings.pt	Fri Jan 26 16:44:29 2018 +0100
@@ -0,0 +1,14 @@
+<div class="top-menu" tal:attributes="class view.css_class" i18n:domain="pyams_content">
+	<span class="label" tal:content="view.label | default">Label:</span>
+	<span class="top-selector popover-trigger-element dropdown-toggle btn-success"
+		  data-toggle="dropdown">
+		<i class="fa fa-3x fa-plus-square text-success opaque hint"
+		   data-ams-hint-gravity="w"
+		   title="Create new content" i18n:attributes="title"></i>
+	</span>
+	<ul class="dropdown-menu">
+		<tal:loop repeat="menu view.viewlets">
+			<tal:li replace="structure menu.render()" />
+		</tal:loop>
+	</ul>
+</div>
--- a/src/pyams_content/zmi/tinymce.py	Fri Jan 26 16:43:52 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-from pyams_form.interfaces.form import IForm
-from pyams_skin.interfaces.tinymce import ITinyMCEConfiguration
-from pyams_skin.layer import IPyAMSLayer
-
-# import packages
-from pyams_utils.adapter import adapter_config, ContextRequestAdapter
-
-
-@adapter_config(context=(IForm, IPyAMSLayer), provides=ITinyMCEConfiguration)
-class TinyMCEEditorConfiguration(ContextRequestAdapter):
-    """TinyMCE editor configuration"""
-
-    @property
-    def configuration(self):
-        return {'ams-plugins': 'pyams_content',
-                'ams-plugin-pyams_content-src': '/--static--/pyams_content/js/pyams_content{MyAMS.devext}.js',
-                'ams-plugin-pyams_content-async': 'false',
-                'ams-tinymce-init-callback': 'PyAMS_content.TinyMCE.initEditor'}
--- a/src/pyams_content/zmi/viewlet/__init__.py	Fri Jan 26 16:43:52 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-
-# import packages
--- a/src/pyams_content/zmi/viewlet/toplinks/__init__.py	Fri Jan 26 16:43:52 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-from hypatia.interfaces import ICatalog
-from pyams_content.shared.common.interfaces import IBaseSharedTool, 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
-
-# import packages
-from hypatia.catalog import CatalogQuery
-from hypatia.query import Any, And, Or, NotEq
-from pyams_catalog.query import CatalogResultSet
-from pyams_skin.viewlet.toplinks import TopLinksViewlet, TopLinksMenu
-from pyams_template.template import template_config
-from pyams_utils.list import unique
-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 _
-
-
-@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 site in sorted(registry.getAllUtilitiesRegisteredFor(ISharedSite),
-                           key=lambda x: II18n(x).query_attribute('title', request=self.request) or ''):
-            menu = TopLinksMenu(self.context, self.request, self.__parent__, self)
-            menu.label = II18n(site).query_attribute('title', request=self.request) or site.__name__
-            menu.url = absolute_url(site, self.request, 'admin#dashboard.html')
-            self.viewlets.append(menu)
-
-
-@viewlet_config(name='shared-tools.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=30)
-class SharedToolsMenu(TopLinksViewlet):
-    """Shared tools menu"""
-
-    label = ''
-    css_class = 'top-menu bordered margin-top-10'
-    dropdown_label = _("Shared contents")
-
-    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):
-                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='user-roles.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=90)
-class UserRolesMenu(TopLinksViewlet):
-    """User roles menu"""
-
-    label = ''
-    css_class = 'top-menu bordered margin-top-10'
-    dropdown_label = _("My roles")
-
-    def update(self):
-        super(UserRolesMenu, self).update()
-        catalog = get_utility(ICatalog)
-        params = And(Or(Any(catalog['role:contributor'], {self.request.principal.id}),
-                        Any(catalog['role:manager'], {self.request.principal.id}),
-                        Any(catalog['role:pilot'], {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) or ''):
-            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='user-addings.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=95)
-@template_config(template='templates/user-addings.pt', layer=IAdminLayer)
-class UserAddingsMenu(TopLinksViewlet):
-    """User addings menu"""
-
-    label = ''
-    css_class = 'top-menu margin-top-5-neg'
-    dropdown_label = ''
-
-    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) or ''):
-            menu = TopLinksMenu(self.context, self.request, self.__parent__, self)
-            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)
--- a/src/pyams_content/zmi/viewlet/toplinks/templates/user-addings.pt	Fri Jan 26 16:43:52 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-<div class="top-menu" tal:attributes="class view.css_class" i18n:domain="pyams_content">
-	<span class="label" tal:content="view.label | default">Label:</span>
-	<span class="top-selector popover-trigger-element dropdown-toggle btn-success"
-		  data-toggle="dropdown">
-		<i class="fa fa-3x fa-plus-square text-success opaque hint"
-		   data-ams-hint-gravity="w"
-		   title="Create new content" i18n:attributes="title"></i>
-	</span>
-	<ul class="dropdown-menu">
-		<tal:loop repeat="menu view.viewlets">
-			<tal:li replace="structure menu.render()" />
-		</tal:loop>
-	</ul>
-</div>