# HG changeset patch # User Thierry Florac # Date 1499853494 -7200 # Node ID f356c84860a3636a5704ac3b422b22af1ea87ea3 # Parent 67a6a3b92612afa74d82d151369f4c11c8801086 Added base of view content portlet diff -r 67a6a3b92612 -r f356c84860a3 src/pyams_content/shared/view/portlet/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/view/portlet/__init__.py Wed Jul 12 11:58:14 2017 +0200 @@ -0,0 +1,73 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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_content.shared.view.portlet.interfaces import IViewItemsPortletSettings +from pyams_portal.interfaces import IPortalContext, IPortletRenderer +from pyams_skin.layer import IPyAMSLayer +from pyams_utils.interfaces import PUBLIC_PERMISSION + +# import packages +from pyams_content.workflow import PUBLISHED_STATES +from pyams_portal.portlet import PortletSettings, portlet_config, Portlet, PortletRenderer +from pyams_sequence.utility import get_sequence_target +from pyams_template.template import template_config +from pyams_utils.adapter import adapter_config +from zope.interface import implementer, Interface +from zope.schema.fieldproperty import FieldProperty + +from pyams_content import _ + + +VIEW_PORTLET_NAME = 'pyams_content.portlet.view' + + +@implementer(IViewItemsPortletSettings) +class ViewItemsPortletSettings(PortletSettings): + """View items portlet settings""" + + view = FieldProperty(IViewItemsPortletSettings['view']) + + def get_view(self): + if self.view is not None: + return get_sequence_target(self.view, state=PUBLISHED_STATES) + + def get_items(self, context): + view = self.get_view() + if view is not None: + return view.get_results(context) + + +@portlet_config(permission=PUBLIC_PERMISSION) +class ViewItemsPortlet(Portlet): + """View items portlet""" + + name = VIEW_PORTLET_NAME + label = _("View items") + + toolbar_image = None + toolbar_css_class = 'fa fa-fw fa-2x fa-th-list' + + settings_class = ViewItemsPortletSettings + + +@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IViewItemsPortletSettings), provides=IPortletRenderer) +@template_config(template='templates/view-items-list.pt', layer=IPyAMSLayer) +class ViewItemsPortletRenderer(PortletRenderer): + """View items portlet renderer""" + + label = _("Simple list view") diff -r 67a6a3b92612 -r f356c84860a3 src/pyams_content/shared/view/portlet/interfaces.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/view/portlet/interfaces.py Wed Jul 12 11:58:14 2017 +0200 @@ -0,0 +1,32 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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_portal.interfaces import IPortletSettings + +# import packages +from pyams_sequence.schema import InternalReference + +from pyams_content import _ + + +class IViewItemsPortletSettings(IPortletSettings): + """View items portlet settings interface""" + + view = InternalReference(title=_("Selected view"), + description=_("Reference to the view from which items are extracted"), + required=True) diff -r 67a6a3b92612 -r f356c84860a3 src/pyams_content/shared/view/portlet/templates/view-items-list.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/view/portlet/templates/view-items-list.pt Wed Jul 12 11:58:14 2017 +0200 @@ -0,0 +1,3 @@ +
+ +
diff -r 67a6a3b92612 -r f356c84860a3 src/pyams_content/shared/view/portlet/templates/view-with-images-list.pt diff -r 67a6a3b92612 -r f356c84860a3 src/pyams_content/shared/view/portlet/zmi/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/view/portlet/zmi/__init__.py Wed Jul 12 11:58:14 2017 +0200 @@ -0,0 +1,51 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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_content.shared.view.portlet.interfaces import IViewItemsPortletSettings +from pyams_pagelet.interfaces import IPagelet +from pyams_portal.interfaces import IPortletPreviewer +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=IViewItemsPortletSettings, layer=IPyAMSLayer, + permission=VIEW_SYSTEM_PERMISSION) +class ViewItemsPortletSettingsEditor(PortletSettingsEditor): + """View items portlet settings editor""" + + settings = IViewItemsPortletSettings + + +@adapter_config(name='properties.json', context=(IViewItemsPortletSettings, IPyAMSLayer), provides=IPagelet) +class ViewItemsPortletSettingsAJAXEditor(AJAXEditForm, ViewItemsPortletSettingsEditor): + """View items portlet settings editor, JSON renderer""" + + +@adapter_config(context=(Interface, IPyAMSLayer, Interface, IViewItemsPortletSettings), provides=IPortletPreviewer) +@template_config(template='templates/view-items-list-preview.pt', layer=IPyAMSLayer) +class ViewItemsPortletPreviewer(PortletPreviewer): + """Image portlet previewer""" diff -r 67a6a3b92612 -r f356c84860a3 src/pyams_content/shared/view/portlet/zmi/templates/view-items-list-preview.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/view/portlet/zmi/templates/view-items-list-preview.pt Wed Jul 12 11:58:14 2017 +0200 @@ -0,0 +1,22 @@ + + + + +
+ +
+
+ + No result found + +
+
+ +
+ + + + +
+
+