Index: quintagroup.portlet.collection/trunk/README.txt
===================================================================
--- quintagroup.portlet.collection/trunk/README.txt (revision 1572)
+++ quintagroup.portlet.collection/trunk/README.txt (revision 1572)
@@ -0,0 +1,4 @@
+Introduction
+============
+
+Extended collection portlet
Index: quintagroup.portlet.collection/trunk/docs/HISTORY.txt
===================================================================
--- quintagroup.portlet.collection/trunk/docs/HISTORY.txt (revision 1572)
+++ quintagroup.portlet.collection/trunk/docs/HISTORY.txt (revision 1572)
@@ -0,0 +1,7 @@
+Changelog
+=========
+
+1.0 (xxxx-xx-xx)
+----------------
+
+* Initial release
Index: quintagroup.portlet.collection/trunk/quintagroup/__init__.py
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/__init__.py (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/__init__.py (revision 1572)
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/__init__.py
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/__init__.py (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/__init__.py (revision 1572)
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/__init__.py
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/__init__.py (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/__init__.py (revision 1572)
@@ -0,0 +1,9 @@
+from zope.i18nmessageid import MessageFactory
+MessageFactory = MessageFactory('quintagroup.portlet.collection')
+
+from Products.CMFCore.permissions import setDefaultRoles
+
+PROJECTNAME = "quintagroup.portlet.collection"
+DEFAULT_ADD_CONTENT_PERMISSION = "%s: Add collection portlet" % PROJECTNAME
+
+setDefaultRoles(DEFAULT_ADD_CONTENT_PERMISSION, ('Manager', 'Owner',))
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/browser/configlet.py
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/browser/configlet.py (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/browser/configlet.py (revision 1572)
@@ -0,0 +1,89 @@
+from zope.interface import Interface
+from zope.component import adapts
+from zope.interface import implements
+from zope import schema
+from zope.app.form import CustomWidgetFactory
+from zope.app.form.browser import ObjectWidget
+from zope.app.form.browser import ListSequenceWidget
+from zope.formlib import form
+
+from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.formlib.schema import SchemaAdapterBase
+
+from Products.CMFPlone.interfaces import IPloneSiteRoot
+
+from plone.app.controlpanel.form import ControlPanelForm
+
+from quintagroup.portlet.collection import MessageFactory as _
+from quintagroup.portlet.collection.utils import getStylesVocabulary
+
+
+class IValueTitlePair(Interface):
+ value = schema.TextLine(title=u"value", required=True)
+ title = schema.TextLine(title=u"title", required=False)
+
+class ValueTitlePair(object):
+ implements(IValueTitlePair)
+ def __init__(self, value='', title=''):
+ self.value = value
+ self.title = title
+
+class IQCollectionPortletPanelSchema(Interface):
+
+ portlet_dropdown = schema.List(
+ title=_(u'Dropdown select'),
+ description=_(u"These entries are used for generating dropdown select "
+ "for quintagroup collection portlet. Note: pipe (|) "
+ "symbol is not allowed in the value field."),
+ value_type=schema.Object(IValueTitlePair, title=u"entry"),
+ required=True
+ )
+
+class QCollectionPortletControlPanelAdapter(SchemaAdapterBase):
+ adapts(IPloneSiteRoot)
+ implements(IQCollectionPortletPanelSchema)
+
+ def __init__(self, context):
+ super(QCollectionPortletControlPanelAdapter, self).__init__(context)
+ self.context = context
+ self.pp = getToolByName(context, 'portal_properties', None)
+
+ def get_portlet_dropdown(self):
+ return [ValueTitlePair(v,t) for (v,t) in getStylesVocabulary(self.context)]
+
+ def set_portlet_dropdown(self, value):
+ dropdown_list = []
+ for vt in value:
+ value = vt.value
+ title = vt.title or value
+ dropdown_list.append('%s|%s' % (value, title))
+ self.setValue(dropdown_list)
+
+ portlet_dropdown = property(get_portlet_dropdown, set_portlet_dropdown)
+
+ def setValue(self, value):
+ if self.pp is not None:
+ if getattr(self.pp, 'qcollectionportlet_properties', None) is None:
+ self.pp.addPropertySheet(
+ 'qcollectionportlet_properties',
+ 'QCollection portlet properties'
+ )
+ sheet = getattr(self.pp, 'qcollectionportlet_properties', None)
+ if not sheet.hasProperty('portlet_dropdown'):
+ sheet.manage_addProperty('portlet_dropdown', value, 'lines')
+ else:
+ sheet.manage_changeProperties(portlet_dropdown=value)
+
+valuetitle_widget = CustomWidgetFactory(ObjectWidget, ValueTitlePair)
+combination_widget = CustomWidgetFactory(ListSequenceWidget,
+ subwidget=valuetitle_widget)
+
+class QCollectionPortletControlPanel(ControlPanelForm):
+
+ form_fields = form.FormFields(IQCollectionPortletPanelSchema)
+ form_fields['portlet_dropdown'].custom_widget = combination_widget
+
+ label = _("QCollection portlet settings")
+ description = _("This form is for managing QCollection portlet "
+ "classes available on portlet add/edit form.")
+ form_name = _("QCollection portlet settings")
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/browser/configure.zcml
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/browser/configure.zcml (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/browser/configure.zcml (revision 1572)
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/collection.pt
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/collection.pt (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/collection.pt (revision 1572)
@@ -0,0 +1,62 @@
+
+
+
+
+
+ -
+
+
+
+ Title
+
+
+ Date
+
+
+ More…
+
+
+ Date
+
+
+
+
+
+
+
+
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/collection.py
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/collection.py (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/collection.py (revision 1572)
@@ -0,0 +1,131 @@
+import random
+
+from zope.interface import implements
+from zope.component import getMultiAdapter
+
+from plone.portlets.interfaces import IPortletDataProvider
+from plone.portlet.collection import collection as base
+
+from zope import schema
+from zope.formlib import form
+
+from plone.memoize.instance import memoize
+from plone.memoize import ram
+from plone.memoize.compress import xhtml_compress
+
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+from plone.app.vocabularies.catalog import SearchableTextSourceBinder
+from plone.app.form.widgets.uberselectionwidget import UberSelectionWidget
+
+from Products.ATContentTypes.interface import IATTopic
+from plone.portlet.collection.collection import ICollectionPortlet
+
+from quintagroup.portlet.collection import MessageFactory as _
+
+class IQCollectionPortlet(ICollectionPortlet):
+ """A portlet which based on plone.portlet.collection and
+ adds more functionalities.
+ """
+
+ item_attributes = schema.List(title=_(u"Attributes to display"),
+ description=_(u"description_attributes", default=u"Select attributes to show for collection item."),
+ required=False,
+ default=[u"Title", u"Description"],
+ value_type=schema.Choice(vocabulary='quintagroup.portlet.collection.vocabularies.PortletAttributesVocabulary'))
+
+ styling = schema.Choice(title=_(u"Portlet style"),
+ description=_(u"description_styling", default=u"Choose a css style for the porlet."),
+ required=False,
+ default=u"",
+ vocabulary='quintagroup.portlet.collection.vocabularies.PortletCSSVocabulary')
+
+
+ show_item_more = schema.Bool(title=_(u"Show more... link for collection items."),
+ description=_(u"If enabled, a more... link will appear in the bottom of the each collection item, "
+ "linking to the corresponding item."),
+ required=True,
+ default=True)
+
+ link_title = schema.Bool(title=_(u"Link title."),
+ description=_(u"If enabled, title will be shown as link to corresponding object. "),
+ required=True,
+ default=True)
+
+class Assignment(base.Assignment):
+ """
+ Portlet assignment.
+ This is what is actually managed through the portlets UI and associated
+ with columns.
+ """
+
+ implements(IQCollectionPortlet)
+
+ item_attributes = [u"Title", u"Description"]
+ styling = u""
+ show_item_more = False
+ link_title = True
+
+ def __init__(self, header=u"", target_collection=None, limit=None,
+ random=False, show_more=True, show_dates=False,
+ item_attributes=[], styling=u"", show_item_more=False, link_title=True):
+
+ super(Assignment, self).__init__(header=header,
+ target_collection=target_collection, limit=limit,
+ random=random, show_more=show_more, show_dates=show_dates)
+
+ if len(item_attributes) > 0:
+ self.item_attributes = item_attributes
+ self.styling = styling
+ self.show_item_more = show_item_more
+ self.link_title = link_title
+
+ @property
+ def title(self):
+ """This property is used to give the title of the portlet in the
+ "manage portlets" screen. Here, we use the title that the user gave.
+ """
+ return self.header
+
+
+class Renderer(base.Renderer):
+ """Portlet renderer.
+
+ This is registered in configure.zcml. The referenced page template is
+ rendered, and the implicit variable 'view' will refer to an instance
+ of this class. Other methods can be added and referenced in the template.
+ """
+
+ render = ViewPageTemplateFile('collection.pt')
+
+ def showProperty(self, name):
+ return name in self.data.item_attributes
+
+
+class AddForm(base.AddForm):
+ """Portlet add form.
+
+ This is registered in configure.zcml. The form_fields variable tells
+ zope.formlib which fields to display. The create() method actually
+ constructs the assignment that is being added.
+ """
+ form_fields = form.Fields(IQCollectionPortlet)
+ form_fields['target_collection'].custom_widget = UberSelectionWidget
+
+ label = _(u"Add Collection Portlet")
+ description = _(u"This portlet display a listing of items from a Collection.")
+
+ def create(self, data):
+ return Assignment(**data)
+
+class EditForm(base.EditForm):
+ """Portlet edit form.
+
+ This is registered with configure.zcml. The form_fields variable tells
+ zope.formlib which fields to display.
+ """
+
+ form_fields = form.Fields(IQCollectionPortlet)
+ form_fields['target_collection'].custom_widget = UberSelectionWidget
+
+ label = _(u"Edit Collection Portlet")
+ description = _(u"This portlet display a listing of items from a Collection.")
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/configure.zcml
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/configure.zcml (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/configure.zcml (revision 1572)
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/controlpanel.xml
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/controlpanel.xml (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/controlpanel.xml (revision 1572)
@@ -0,0 +1,12 @@
+
+
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/metadata.xml
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/metadata.xml (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/metadata.xml (revision 1572)
@@ -0,0 +1,4 @@
+
+
+ 0.1
+
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/portlets.xml
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/portlets.xml (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/portlets.xml (revision 1572)
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/propertiestool.xml
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/propertiestool.xml (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/profiles/default/propertiestool.xml (revision 1572)
@@ -0,0 +1,9 @@
+
+
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/utils.py
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/utils.py (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/utils.py (revision 1572)
@@ -0,0 +1,26 @@
+"""Somme utility functions for common use"""
+from Products.CMFCore.utils import getToolByName
+
+def getStylesVocabulary(context):
+ pp = getToolByName(context, 'portal_properties', None)
+ styles = None
+ if pp is not None:
+ sheet = getattr(pp, 'qcollectionportlet_properties', None)
+ if sheet is not None:
+ dropdown_list = sheet.getProperty('portlet_dropdown', None)
+ if dropdown_list is not None:
+ styles = []
+ value_list = []
+ for line in dropdown_list:
+ values = filter(lambda x:x.strip(), line.split('|', 1))
+ if len(values) == 0:
+ continue
+ elif len(values) == 1:
+ value = title = values[0]
+ else:
+ value = values[0]
+ title = values[1]
+ if value not in value_list:
+ value_list.append(value)
+ styles.append((value, title))
+ return styles
Index: quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/vocabularies.py
===================================================================
--- quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/vocabularies.py (revision 1572)
+++ quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/vocabularies.py (revision 1572)
@@ -0,0 +1,59 @@
+from zope.app.schema.vocabulary import IVocabularyFactory
+from zope.interface import implements
+from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
+
+from Products.CMFCore.utils import getToolByName
+
+from quintagroup.portlet.collection import MessageFactory as _
+from quintagroup.portlet.collection.utils import getStylesVocabulary
+
+PORTLET_CSS_STYLES = (
+ (u"class1", _(u"Class1")),
+ (u"class2", _(u"Class2")),
+)
+
+PORTLET_ATTRIBUTES_TO_SHOW = (
+ (u"Title", _(u"Title")),
+ (u"Description", _(u"Description")),
+)
+
+class PortletCSSVocabulary(object):
+ implements(IVocabularyFactory)
+
+
+ def __call__(self, context):
+ styles = getStylesVocabulary(context)
+ if styles is None:
+ styles = PORTLET_CSS_STYLES
+ charset = self._charset(context)
+ items = []
+ for value, title in styles:
+ if not isinstance(title, unicode):
+ title = title.decode(charset)
+ if not isinstance(value, unicode):
+ value = value.decode(charset)
+ items.append(SimpleTerm(value, value, _(title)))
+ return SimpleVocabulary(items)
+
+ items = [SimpleTerm(value, value, title) for value, title in PORTLET_CSS_STYLES]
+ return SimpleVocabulary(items)
+
+ def _charset(self, context):
+ pp = getToolByName(context, 'portal_properties', None)
+ if pp is not None:
+ site_properties = getattr(pp, 'site_properties', None)
+ if site_properties is not None:
+ return site_properties.getProperty('default_charset', 'utf-8')
+ return 'utf-8'
+
+PortletCSSVocabulary = PortletCSSVocabulary()
+
+class PortletAttributesVocabulary(object):
+ implements(IVocabularyFactory)
+
+ def __call__(self, context):
+ items = [SimpleTerm(value, value, title) for value, title in PORTLET_ATTRIBUTES_TO_SHOW]
+ return SimpleVocabulary(items)
+
+PortletAttributesVocabulary = PortletAttributesVocabulary()
+
Index: quintagroup.portlet.collection/trunk/setup.cfg
===================================================================
--- quintagroup.portlet.collection/trunk/setup.cfg (revision 1572)
+++ quintagroup.portlet.collection/trunk/setup.cfg (revision 1572)
@@ -0,0 +1,3 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
Index: quintagroup.portlet.collection/trunk/setup.py
===================================================================
--- quintagroup.portlet.collection/trunk/setup.py (revision 1572)
+++ quintagroup.portlet.collection/trunk/setup.py (revision 1572)
@@ -0,0 +1,32 @@
+from setuptools import setup, find_packages
+import os
+
+version = '1.0'
+
+setup(name='quintagroup.portlet.collection',
+ version=version,
+ description="Extended collection portlet",
+ long_description=open("README.txt").read() + "\n" +
+ open(os.path.join("docs", "HISTORY.txt")).read(),
+ # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
+ classifiers=[
+ "Programming Language :: Python",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+ ],
+ keywords='portlet collection quintagroup',
+ author='Melnychuk Taras',
+ author_email='fenix@quintagroup.com',
+ url='',
+ license='GPL',
+ packages=find_packages(exclude=['ez_setup']),
+ namespace_packages=['quintagroup', 'quintagroup.portlet'],
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=[
+ 'setuptools',
+ # -*- Extra requirements: -*-
+ ],
+ entry_points="""
+ # -*- Entry points: -*-
+ """,
+ )