--- a/src/pyams_portal/interfaces/__init__.py Wed Sep 12 16:44:03 2018 +0200
+++ b/src/pyams_portal/interfaces/__init__.py Thu Sep 13 16:30:44 2018 +0200
@@ -17,19 +17,17 @@
# import interfaces
from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.container.constraints import contains
from zope.container.interfaces import IContainer
from zope.contentprovider.interfaces import IContentProvider
+from zope.interface import Interface, Attribute
from zope.location.interfaces import ILocation, IContained
+from zope.schema import List, TextLine, Object, Int, Bool, Choice
+from pyams_portal import _
# import packages
from pyams_security.schema import PermissionField
from pyams_utils.schema import PersistentDict, PersistentList
-from zope.container.constraints import contains
-from zope.interface import Interface, Attribute
-from zope.schema import List, TextLine, Object, Int, Bool, Choice
-
-from pyams_portal import _
-
MANAGE_TEMPLATE_PERMISSION = 'pyams_portal.manage_template'
@@ -62,6 +60,10 @@
settings_factory = Attribute("Portlet settings factory")
+class IPortletCSSClass(Interface):
+ """Portlet CSS class interface"""
+
+
class IPortletAddingInfo(Interface):
"""Portlet adding info interface"""
--- a/src/pyams_portal/portlet.py Wed Sep 12 16:44:03 2018 +0200
+++ b/src/pyams_portal/portlet.py Thu Sep 13 16:30:44 2018 +0200
@@ -44,7 +44,7 @@
from pyramid.threadlocal import get_current_registry
from zope.container.contained import Contained
from zope.copy import clone
-from zope.interface import implementer, alsoProvides, noLongerProvides, Interface
+from zope.interface import implementer, alsoProvides, noLongerProvides
from zope.lifecycleevent import ObjectCreatedEvent
from zope.location import locate
from zope.schema.fieldproperty import FieldProperty
--- a/src/pyams_portal/templates/pagelet.pt Wed Sep 12 16:44:03 2018 +0200
+++ b/src/pyams_portal/templates/pagelet.pt Thu Sep 13 16:30:44 2018 +0200
@@ -10,8 +10,8 @@
tal:condition="slot_config.visible"
tal:attributes="class string:slot col ${slot_config.get_css_class()}">
<div class="portlets">
- <div class="portlet"
- tal:repeat="portlet_id template_config.slot_config[slot_name].portlet_ids">
+ <div tal:repeat="portlet_id template_config.slot_config[slot_name].portlet_ids"
+ class="portlet ${view.get_portlet_css_class(portlet_id)}">
<tal:var replace="structure view.render_portlet(portlet_id)">Content</tal:var>
</div>
</div>
--- a/src/pyams_portal/views.py Wed Sep 12 16:44:03 2018 +0200
+++ b/src/pyams_portal/views.py Thu Sep 13 16:30:44 2018 +0200
@@ -15,19 +15,19 @@
# import standard library
-# import interfaces
-from pyams_portal.interfaces import IPortalContext, IPortalPage, IPortalTemplateConfiguration, \
- IPortalPortletsConfiguration, IPortletRenderer, IPortlet, PREVIEW_MODE
-from pyams_skin.layer import IPyAMSUserLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_workflow.interfaces import IWorkflowPublicationInfo
+from pyramid.decorator import reify
+from pyramid.exceptions import NotFound
# import packages
from pyams_default_theme.page import BaseIndexPage
from pyams_pagelet.pagelet import pagelet_config
+# import interfaces
+from pyams_portal.interfaces import IPortalContext, IPortalPage, IPortalTemplateConfiguration, \
+ IPortalPortletsConfiguration, IPortletRenderer, IPortlet, PREVIEW_MODE, IPortletCSSClass
+from pyams_skin.layer import IPyAMSUserLayer
from pyams_template.template import template_config
-from pyramid.decorator import reify
-from pyramid.exceptions import NotFound
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+from pyams_workflow.interfaces import IWorkflowPublicationInfo
class BasePortalContextIndexPage(BaseIndexPage):
@@ -67,6 +67,11 @@
def get_portlet(self, name):
return self.request.registry.getUtility(IPortlet, name=name)
+ def get_portlet_css_class(self, portlet_id):
+ configuration = self.portlet_configuration.get_portlet_configuration(portlet_id)
+ portlet = self.get_portlet(configuration.portlet_name)
+ return self.request.registry.queryMultiAdapter((portlet, self.request), IPortletCSSClass, default='')
+
def render_portlet(self, portlet_id):
renderer = self.portlets.get(portlet_id)
if renderer is not None: