--- a/src/pyams_portal/interfaces/__init__.py Thu Oct 08 12:26:42 2015 +0200
+++ b/src/pyams_portal/interfaces/__init__.py Mon Jan 18 18:09:46 2016 +0100
@@ -16,10 +16,10 @@
# import standard library
# import interfaces
-from pyams_workflow.interfaces import IWorkflowManagedContent
from zope.annotation.interfaces import IAttributeAnnotatable
from zope.container.interfaces import IContainer
from zope.contentprovider.interfaces import IContentProvider
+from zope.location.interfaces import ILocation, IContained
# import packages
from pyams_security.schema import PermissionField
@@ -31,21 +31,33 @@
from pyams_portal import _
+MANAGE_TEMPLATE_PERMISSION = 'pyams_portal.manage_template'
+
+
+#
+# Portlet interfaces
+#
+
class IPortlet(Interface):
- """Portlet interface"""
+ """Portlet utility interface
+
+ Portlets are registered utilities providing IPortlet
+ """
name = Attribute("Portlet internal name")
label = Attribute("Portlet visible name")
permission = PermissionField(title="Portlet permission",
- description="Permission required to display permission",
+ description="Permission required to display portlet",
required=False)
- toolbar_image = Attribute("Porlet toolbar image")
+ toolbar_image = Attribute("Portlet toolbar image")
toolbar_css_class = Attribute("Portlet toolbar CSS class")
+ settings_class = Attribute("Portlet settings class")
+
class IPortletAddingInfo(Interface):
"""Portlet adding info interface"""
@@ -59,35 +71,53 @@
vocabulary='PyAMS template slots')
-class IPortletConfiguration(Interface):
- """Portlet configuration interface"""
+class IPortletSettings(ILocation, IAttributeAnnotatable):
+ """Portlet settings interface
+
+ Portlet settings is parented to it's configuration
+ """
+
+ configuration = Attribute("Settings parent configuration")
+
+ visible = Bool(title=_("Visible portlet?"),
+ description=_("Select 'no' to hide this portlet..."),
+ required=True,
+ default=True)
+
- template = Attribute("Template to which this configuration applis")
+PORTLETS_CONFIGURATION_KEY = 'pyams_portal.portlets'
+
+
+class IPortletConfiguration(ILocation):
+ """Portlet common configuration interface
- slot_name = TextLine(title=_("Slot name"),
- description=_("Slot name to which this configuration applies"),
- required=True)
+ This is generic configuration settings common to all portlets.
+ Portlet configuration is parented to:
+ - it's template if parent is the template
+ - it's context if parent is a portal context
+ """
+
+ portlet_id = Int(title="Portlet ID",
+ required=True)
portlet_name = Attribute("Portlet name")
- position = Int(title=_("Position"),
- description=_("Portlet position inside slot"),
- required=True,
- min=0)
-
- visible = Bool(title=_("Visible portlet?"),
- description=_("Select 'no' to hide this portlet. This will not break configuration inheritance..."),
- required=True,
- default=True)
-
can_inherit = Attribute("Can inherit parent configuration?")
+ parent = Attribute("Portlet configuration parent")
+
inherit_parent = Bool(title=_("Inherit parent configuration?"),
- description=_("This option is only available if context's parent is using the same template "
- "and if this portlet is also present in the same slot..."),
+ description=_("This option is only available if context's parent is using the same "
+ "template..."),
required=True,
default=True)
+ settings = Object(title="Portlet local settings",
+ schema=IPortletSettings,
+ readonly=True)
+
+ editor_settings = Attribute("Editor settings")
+
class IPortletContentProvider(IContentProvider):
"""Portlet content provider"""
@@ -115,6 +145,26 @@
"""
+class IPortalPortletsConfiguration(IContained):
+ """Portal template portlet configuration interface"""
+
+ def get_portlet_configuration(self, portlet_id):
+ """Get portlet configuration for given slot"""
+
+ def set_portlet_configuration(self, portlet_id, config):
+ """Set portlet configuration"""
+
+ def delete_portlet_configuration(self, portlet_id):
+ """Delete portlet configuration"""
+
+
+#
+# Slot interfaces
+#
+
+PORTAL_SLOTS_KEY = 'pyams_portal.slots'
+
+
class ISlot(Interface):
"""Portal template slot interface"""
@@ -133,19 +183,14 @@
slot_name = TextLine(title="Slot name")
+ portlet_ids = PersistentList(title="Portlet IDs",
+ value_type=Int())
+
visible = Bool(title=_("Visible slot?"),
- description=_("Select 'no' to hide this slot. This will not break configuration inheritance..."),
+ description=_("Select 'no' to hide this slot..."),
required=True,
default=True)
- can_inherit = Attribute("Can inherit parent configuration?")
-
- inherit_parent = Bool(title=_("Inherit parent configuration?"),
- description=_("This option is only available if context's parent template is using a "
- "template containing the same slot..."),
- required=True,
- default=True)
-
xs_width = Int(title=_("Extra small device width"),
description=_("Slot width, in columns count, on extra small devices (phones...); "
"set to 0 to hide the portlet"),
@@ -192,9 +237,14 @@
"""Slot renderer"""
-class IPortalTemplateConfiguration(Interface):
+#
+# Template configuration interfaces
+#
+
+class IPortalTemplateConfiguration(IContained):
"""Portal template configuration interface"""
+ # Rows configuration
rows = Int(title="Rows count",
required=True,
default=1,
@@ -209,6 +259,7 @@
def delete_row(self, row_id):
"""Delete template row"""
+ # Slots configuration
slot_names = PersistentList(title="Slot names",
value_type=TextLine())
@@ -216,14 +267,6 @@
key_type=Int(), # row index
value_type=PersistentList(value_type=TextLine())) # slot name
- slots = PersistentDict(title="Slots portlets",
- description="List of slots associated with a given template",
- key_type=Int(), # row index
- value_type=PersistentDict(key_type=TextLine(), # slot name
- value_type=PersistentList(value_type=Choice(
- vocabulary='PyAMS portal portlets')), # portlet names
- required=False))
-
slot_config = PersistentDict(title="Slots configuration",
key_type=TextLine(), # slot name
value_type=Object(schema=ISlotConfiguration),
@@ -253,33 +296,39 @@
def delete_slot(self, slot_name):
"""Delete template slot"""
-
-# class IPortalPortletsConfiguration(Interface):
-# """Portal template portlets configuration interface"""
-#
- portlet_config = PersistentDict(title="Portlet configuration",
- key_type=TextLine(), # slot name
- value_type=PersistentDict(key_type=Int(min=0), # portlet position inside slot
- value_type=Object(schema=IPortletConfiguration)),
- required=False)
-
+ # Portlets configuration
def add_portlet(self, portlet_name, slot_name):
"""Add portlet to givben slot"""
- def set_portlet_order(self, order):
- """Set template portlets order"""
+ def get_portlet_slot(self, portlet_id):
+ """Get row ID and slot for given portlet"""
- def get_portlet_configuration(self, slot_name, position):
- """Get portlet configuration for given slot"""
+ def set_portlet_order(self, slot_name, order):
+ """Set template portlets order"""
def delete_portlet(self, slot_name, position):
"""Delete template portlet"""
-class IPortalTemplate(IAttributeAnnotatable):
+#
+# Portal templates interfaces
+#
+
+TEMPLATE_CONFIGURATION_KEY = 'pyams_portal.template'
+
+TEMPLATE_CONTAINER_CONFIGURATION_KEY = 'pyams_portal.container.configuration'
+
+PORTAL_PAGE_KEY = 'pyams_portal.page'
+
+
+class ILocalTemplateHandler(IAttributeAnnotatable):
+ """Base interface for local template handler"""
+
+
+class IPortalTemplate(ILocalTemplateHandler):
"""Portal template interface
- A portal template is a named utility providing a name and a set of slots.
+ A portal template is a named utility providing a name and a set of slots containing portlets
"""
name = TextLine(title=_("Template name"),
@@ -287,24 +336,28 @@
required=True)
-class IPortalWfTemplate(IWorkflowManagedContent):
- """Workflow managed portal template interface"""
-
-
class IPortalTemplateContainer(IContainer, IAttributeAnnotatable):
"""Portal template container interface"""
contains(IPortalTemplate)
+ last_portlet_id = Int(title="Last portlet ID",
+ required=True,
+ default=1,
+ min=0)
+
+ def get_portlet_id(self):
+ """Get new portlet ID"""
+
class IPortalTemplateContainerConfiguration(Interface):
"""Portal templates container configuration"""
- selected_portlets = List(title=_("Selected portlets"),
- description=_("These portlets will be directly available in templates configuration "
- "page toolbar"),
- value_type=Choice(vocabulary="PyAMS portal portlets"),
- required=False)
+ toolbar_portlets = List(title=_("Toolbar portlets"),
+ description=_("These portlets will be directly available in templates configuration "
+ "page toolbar"),
+ value_type=Choice(vocabulary="PyAMS portal portlets"),
+ required=False)
class IPortalTemplateRenderer(IContentProvider):
@@ -320,11 +373,13 @@
The page is the highest configuration level.
It defines which template is used (a shared or local one), which gives
- the slots list.
+ the slot and portlet lists.
"""
can_inherit = Attribute("Can inherit parent template?")
+ parent = Attribute("Parent from which to inherit, the real parent or the source template")
+
inherit_parent = Bool(title=_("Inherit parent template?"),
description=_("Should we reuse parent template?"),
required=True,
@@ -347,7 +402,7 @@
raise Invalid(_("You must choose to use a local template or select a shared one!"))
local_template = Object(title=_("Local template"),
- schema=IPortalWfTemplate,
+ schema=IPortalTemplate,
required=False)
template = Attribute("Used template")