Reorganized ZMI modules
authorThierry Florac <tflorac@ulthar.net>
Sun, 11 Mar 2018 11:04:20 +0100
changeset 66 5f2a36c93535
parent 65 5c9edb045032
child 67 d121b3645219
Reorganized ZMI modules
src/pyams_portal/portlets/content/__init__.py
src/pyams_portal/portlets/content/zmi/__init__.py
src/pyams_portal/portlets/content/zmi/preview.pt
src/pyams_portal/portlets/image/__init__.py
src/pyams_portal/portlets/image/zmi/__init__.py
src/pyams_portal/portlets/image/zmi/preview.pt
src/pyams_portal/zmi/portlets/__init__.py
src/pyams_portal/zmi/portlets/content.py
src/pyams_portal/zmi/portlets/image.py
src/pyams_portal/zmi/portlets/templates/context-preview.pt
src/pyams_portal/zmi/portlets/templates/image-preview.pt
--- a/src/pyams_portal/portlets/content/__init__.py	Sun Mar 11 11:03:46 2018 +0100
+++ b/src/pyams_portal/portlets/content/__init__.py	Sun Mar 11 11:04:20 2018 +0100
@@ -19,7 +19,7 @@
 from .interfaces import IContentPortletSettings
 from pyams_portal.interfaces import IPortletRenderer, IPortalContext
 from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import PUBLIC_PERMISSION
+from pyams_utils.interfaces import VIEW_PERMISSION
 
 # import packages
 from pyams_portal.portlet import PortletSettings, Portlet, PortletRenderer, portlet_config
@@ -38,7 +38,7 @@
     """Content portlet persistent settings"""
 
 
-@portlet_config(permission=PUBLIC_PERMISSION)
+@portlet_config(permission=VIEW_PERMISSION)
 class ContentPortlet(Portlet):
     """Content portlet"""
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/content/zmi/__init__.py	Sun Mar 11 11:04:20 2018 +0100
@@ -0,0 +1,52 @@
+#
+# 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_pagelet.interfaces import IPagelet
+from pyams_portal.interfaces import IPortletPreviewer
+from pyams_portal.portlets.content.interfaces import IContentPortletSettings
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+
+# import packages
+from pyams_form.form import AJAXEditForm
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_portal.portlet import PortletPreviewer
+from pyams_portal.zmi.portlet import PortletSettingsEditor
+from pyams_template.template import template_config
+from pyams_utils.adapter import adapter_config
+from zope.interface import Interface
+
+
+@pagelet_config(name='properties.html', context=IContentPortletSettings, request_type=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
+class ContentPortletSettingsEditor(PortletSettingsEditor):
+    """Content portlet settings editor"""
+
+    settings = IContentPortletSettings
+
+
+@adapter_config(name='properties.json', context=(IContentPortletSettings, IPyAMSLayer), provides=IPagelet)
+class ContentPortletConfigurationAJAXEditor(AJAXEditForm, ContentPortletSettingsEditor):
+    """Content portlet settings editor, AJAX renderer"""
+
+
+@adapter_config(context=(Interface, IPyAMSLayer, Interface, IContentPortletSettings),
+                provides=IPortletPreviewer)
+@template_config(template='preview.pt', layer=IPyAMSLayer)
+class ContentPortletPreviewer(PortletPreviewer):
+    """Content portlet previewer"""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/content/zmi/preview.pt	Sun Mar 11 11:04:20 2018 +0100
@@ -0,0 +1,11 @@
+<tal:var define="settings view.settings">
+	<tal:if condition="settings.visible">This is my preview !!</tal:if>
+	<tal:if condition="not settings.visible">
+		<div class="text-center padding-y-5">
+			<span class="fa-stack fa-lg">
+				<i class="fa fa-eye fa-stack-1x"></i>
+				<i class="fa fa-ban fa-stack-2x text-danger"></i>
+			</span>
+		</div>
+	</tal:if>
+</tal:var>
--- a/src/pyams_portal/portlets/image/__init__.py	Sun Mar 11 11:03:46 2018 +0100
+++ b/src/pyams_portal/portlets/image/__init__.py	Sun Mar 11 11:04:20 2018 +0100
@@ -20,7 +20,7 @@
 from pyams_file.interfaces import IResponsiveImage, DELETED_FILE
 from pyams_portal.interfaces import IPortalContext, IPortletRenderer
 from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import PUBLIC_PERMISSION
+from pyams_utils.interfaces import VIEW_PERMISSION
 
 # import packages
 from pyams_file.property import FileProperty
@@ -52,7 +52,7 @@
             alsoProvides(self._image, IResponsiveImage)
 
 
-@portlet_config(permission=PUBLIC_PERMISSION)
+@portlet_config(permission=VIEW_PERMISSION)
 class ImagePortlet(Portlet):
     """Image portlet"""
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/image/zmi/__init__.py	Sun Mar 11 11:04:20 2018 +0100
@@ -0,0 +1,51 @@
+#
+# 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_pagelet.interfaces import IPagelet
+from pyams_portal.interfaces import IPortletPreviewer
+from pyams_portal.portlets.image.interfaces import IImagePortletSettings
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+
+# import packages
+from pyams_form.form import AJAXEditForm
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_portal.portlet import PortletPreviewer
+from pyams_portal.zmi.portlet import PortletSettingsEditor
+from pyams_template.template import template_config
+from pyams_utils.adapter import adapter_config
+from zope.interface import Interface
+
+
+@pagelet_config(name='properties.html', context=IImagePortletSettings, request_type=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
+class ImagePortletSettingsEditor(PortletSettingsEditor):
+    """Image portlet settings editor"""
+
+    settings = IImagePortletSettings
+
+
+@adapter_config(name='properties.json', context=(IImagePortletSettings, IPyAMSLayer), provides=IPagelet)
+class ImagePortletConfigurationAJAXEditor(AJAXEditForm, ImagePortletSettingsEditor):
+    """Image portlet settings editor, AJAX renderer"""
+
+
+@adapter_config(context=(Interface, IPyAMSLayer, Interface, IImagePortletSettings), provides=IPortletPreviewer)
+@template_config(template='preview.pt', layer=IPyAMSLayer)
+class ImagePortletPreviewer(PortletPreviewer):
+    """Image portlet previewer"""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/image/zmi/preview.pt	Sun Mar 11 11:04:20 2018 +0100
@@ -0,0 +1,76 @@
+<tal:var define="settings view.settings">
+	<tal:if condition="settings.visible">
+		<tal:if condition="settings.image">
+			<a class="fancybox" data-toggle
+			   data-ams-fancybox-type="image"
+			   tal:define="image settings.image;
+						   image_url extension:absolute_url(image);
+						   slot_config view.slot_configuration;
+						   slot_width slot_config.get_width();
+						   base_width 100 / 12;
+						   thumbnails extension:thumbnails(image);
+						   target python:thumbnails.get_thumbnail('800x600');"
+			   tal:attributes="href extension:absolute_url(target)">
+				<picture>
+					<tal:var define="width slot_width['lg']">
+						<source media="(min-width: 1200px)"
+								tal:condition="width"
+								tal:attributes="srcset string:${image_url}/++thumb++lg:w1200 1200w, ${image_url}/++thumb++lg:w512 512w, ${image_url}/++thumb++lg:w256 256w, ${image_url}/++thumb++lg:w128 128w;
+												sizes string:${round(base_width * width)}vw" />
+						<source media="(min-width: 1200px)"
+								srcset="/--static--/pyams_default_theme/img/dot.png"
+								tal:condition="not:width"
+								tal:attributes="sizes string:${round(base_width * width)}vw" />
+					</tal:var>
+					<tal:var define="width slot_width['md']">
+						<source media="(min-width: 992px)"
+								tal:condition="width"
+								tal:attributes="srcset string:${image_url}/++thumb++md:w992 992w, ${image_url}/++thumb++md:w512 512w, ${image_url}/++thumb++md:w256 256w, ${image_url}/++thumb++md:w128 128w;
+												sizes string:${round(base_width * width)}vw" />
+						<source media="(min-width: 992px)"
+								srcset="/--static--/pyams_default_theme/img/dot.png"
+								tal:condition="not:width"
+								tal:attributes="sizes string:${round(base_width * width)}vw" />
+					</tal:var>
+					<tal:var define="width slot_width['sm']">
+						<source media="(min-width: 768px)"
+								tal:condition="width"
+								tal:attributes="srcset string:${image_url}/++thumb++sm:w768 768w, ${image_url}/++thumb++sm:w512 512w, ${image_url}/++thumb++sm:w256 256w, ${image_url}/++thumb++sm:w128 128w;
+												sizes string:${round(base_width * width)}vw" />
+						<source media="(min-width: 768px)"
+								srcset="/--static--/pyams_default_theme/img/dot.png"
+								tal:condition="not:width"
+								tal:attributes="sizes string:${round(base_width * width)}vw" />
+					</tal:var>
+					<tal:var define="width slot_width['xs']">
+						<source media="(max-width: 767px)"
+								tal:condition="width"
+								tal:attributes="srcset string:${image_url}/++thumb++xs:w768 768w, ${image_url}/++thumb++xs:w512 512w, ${image_url}/++thumb++xs:w256 256w, ${image_url}/++thumb++xs:w128 128w;
+												sizes string:${round(base_width * width)}vw" />
+						<source media="(max-width: 767px)"
+								srcset="/--static--/pyams_default_theme/img/dot.png"
+								tal:condition="not:width"
+								tal:attributes="sizes string:${round(base_width * width)}vw" />
+					</tal:var>
+					<img style="width: 100%;" tal:attributes="src image_url" />
+				</picture>
+			</a>
+		</tal:if>
+		<tal:if condition="not settings.image">
+			<div class="text-center padding-y-5">
+				<span class="fa-stack fa-lg">
+					<i class="fa fa-picture-o fa-stack-1x"></i>
+					<i class="fa fa-ban fa-stack-2x text-danger"></i>
+				</span>
+			</div>
+		</tal:if>
+	</tal:if>
+	<tal:if condition="not settings.visible">
+		<div class="text-center padding-y-5">
+			<span class="fa-stack fa-lg">
+				<i class="fa fa-eye fa-stack-1x"></i>
+				<i class="fa fa-ban fa-stack-2x text-danger"></i>
+			</span>
+		</div>
+	</tal:if>
+</tal:var>
--- a/src/pyams_portal/zmi/portlets/__init__.py	Sun Mar 11 11:03:46 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_portal/zmi/portlets/content.py	Sun Mar 11 11:03:46 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +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_pagelet.interfaces import IPagelet
-from pyams_portal.interfaces import IPortletPreviewer
-from pyams_portal.portlets.content.interfaces import IContentPortletSettings
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-
-# import packages
-from pyams_form.form import AJAXEditForm
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_portal.portlet import PortletPreviewer
-from pyams_portal.zmi.portlet import PortletSettingsEditor
-from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config
-from zope.interface import Interface
-
-
-@pagelet_config(name='properties.html', context=IContentPortletSettings, request_type=IPyAMSLayer,
-                permission=VIEW_SYSTEM_PERMISSION)
-class ContentPortletSettingsEditor(PortletSettingsEditor):
-    """Content portlet settings editor"""
-
-    settings = IContentPortletSettings
-
-
-@adapter_config(name='properties.json', context=(IContentPortletSettings, IPyAMSLayer), provides=IPagelet)
-class ContentPortletConfigurationAJAXEditor(AJAXEditForm, ContentPortletSettingsEditor):
-    """Content portlet settings editor, AJAX renderer"""
-
-
-@adapter_config(context=(Interface, IPyAMSLayer, Interface, IContentPortletSettings),
-                provides=IPortletPreviewer)
-@template_config(template='templates/context-preview.pt', layer=IPyAMSLayer)
-class ContentPortletPreviewer(PortletPreviewer):
-    """Content portlet previewer"""
--- a/src/pyams_portal/zmi/portlets/image.py	Sun Mar 11 11:03:46 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +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_pagelet.interfaces import IPagelet
-from pyams_portal.interfaces import IPortletPreviewer, IPortalPage, IPortalTemplate, IPortalTemplateConfiguration
-from pyams_portal.portlets.image.interfaces import IImagePortletSettings
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-
-# import packages
-from pyams_form.form import AJAXEditForm
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_portal.portlet import PortletPreviewer
-from pyams_portal.zmi.portlet import PortletSettingsEditor
-from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config
-from zope.interface import Interface
-
-
-@pagelet_config(name='properties.html', context=IImagePortletSettings, request_type=IPyAMSLayer,
-                permission=VIEW_SYSTEM_PERMISSION)
-class ImagePortletSettingsEditor(PortletSettingsEditor):
-    """Image portlet settings editor"""
-
-    settings = IImagePortletSettings
-
-
-@adapter_config(name='properties.json', context=(IImagePortletSettings, IPyAMSLayer), provides=IPagelet)
-class ImagePortletConfigurationAJAXEditor(AJAXEditForm, ImagePortletSettingsEditor):
-    """Image portlet settings editor, AJAX renderer"""
-
-
-@adapter_config(context=(Interface, IPyAMSLayer, Interface, IImagePortletSettings), provides=IPortletPreviewer)
-@template_config(template='templates/image-preview.pt', layer=IPyAMSLayer)
-class ImagePortletPreviewer(PortletPreviewer):
-    """Image portlet previewer"""
--- a/src/pyams_portal/zmi/portlets/templates/context-preview.pt	Sun Mar 11 11:03:46 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-This is my preview !!
--- a/src/pyams_portal/zmi/portlets/templates/image-preview.pt	Sun Mar 11 11:03:46 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-<tal:var define="settings view.settings">
-	<tal:if condition="settings.visible">
-		<tal:if condition="settings.image">
-			<a class="fancybox" data-toggle
-			   data-ams-fancybox-type="image"
-			   tal:define="image settings.image;
-						   image_url extension:absolute_url(image);
-						   slot_config view.slot_configuration;
-						   slot_width slot_config.get_width();
-						   base_width 100 / 12;
-						   thumbnails extension:thumbnails(image);
-						   target python:thumbnails.get_thumbnail('800x600');"
-			   tal:attributes="href extension:absolute_url(target)">
-				<picture>
-					<tal:var define="width slot_width['lg']">
-						<source media="(min-width: 1200px)"
-								tal:condition="width"
-								tal:attributes="srcset string:${image_url}/++thumb++lg:w1200 1200w, ${image_url}/++thumb++lg:w512 512w, ${image_url}/++thumb++lg:w256 256w, ${image_url}/++thumb++lg:w128 128w;
-												sizes string:${round(base_width * width)}vw" />
-						<source media="(min-width: 1200px)"
-								srcset="/--static--/pyams_default_theme/img/dot.png"
-								tal:condition="not:width"
-								tal:attributes="sizes string:${round(base_width * width)}vw" />
-					</tal:var>
-					<tal:var define="width slot_width['md']">
-						<source media="(min-width: 992px)"
-								tal:condition="width"
-								tal:attributes="srcset string:${image_url}/++thumb++md:w992 992w, ${image_url}/++thumb++md:w512 512w, ${image_url}/++thumb++md:w256 256w, ${image_url}/++thumb++md:w128 128w;
-												sizes string:${round(base_width * width)}vw" />
-						<source media="(min-width: 992px)"
-								srcset="/--static--/pyams_default_theme/img/dot.png"
-								tal:condition="not:width"
-								tal:attributes="sizes string:${round(base_width * width)}vw" />
-					</tal:var>
-					<tal:var define="width slot_width['sm']">
-						<source media="(min-width: 768px)"
-								tal:condition="width"
-								tal:attributes="srcset string:${image_url}/++thumb++sm:w768 768w, ${image_url}/++thumb++sm:w512 512w, ${image_url}/++thumb++sm:w256 256w, ${image_url}/++thumb++sm:w128 128w;
-												sizes string:${round(base_width * width)}vw" />
-						<source media="(min-width: 768px)"
-								srcset="/--static--/pyams_default_theme/img/dot.png"
-								tal:condition="not:width"
-								tal:attributes="sizes string:${round(base_width * width)}vw" />
-					</tal:var>
-					<tal:var define="width slot_width['xs']">
-						<source media="(max-width: 767px)"
-								tal:condition="width"
-								tal:attributes="srcset string:${image_url}/++thumb++xs:w768 768w, ${image_url}/++thumb++xs:w512 512w, ${image_url}/++thumb++xs:w256 256w, ${image_url}/++thumb++xs:w128 128w;
-												sizes string:${round(base_width * width)}vw" />
-						<source media="(max-width: 767px)"
-								srcset="/--static--/pyams_default_theme/img/dot.png"
-								tal:condition="not:width"
-								tal:attributes="sizes string:${round(base_width * width)}vw" />
-					</tal:var>
-					<img style="width: 100%;" tal:attributes="src image_url" />
-				</picture>
-			</a>
-		</tal:if>
-		<tal:if condition="not settings.image">
-			<div class="text-center padding-y-5">
-				<span class="fa-stack fa-lg">
-					<i class="fa fa-picture-o fa-stack-1x"></i>
-					<i class="fa fa-ban fa-stack-2x text-danger"></i>
-				</span>
-			</div>
-		</tal:if>
-	</tal:if>
-	<tal:if condition="not settings.visible">
-		<div class="text-center padding-y-5">
-			<span class="fa-stack fa-lg">
-				<i class="fa fa-eye fa-stack-1x"></i>
-				<i class="fa fa-ban fa-stack-2x text-danger"></i>
-			</span>
-		</div>
-	</tal:if>
-</tal:var>