# HG changeset patch # User Thierry Florac # Date 1536849044 -7200 # Node ID 561b132c6f143ac350ad4b79f4f0a2a9180ce562 # Parent b3a4f4e2c9597ef5e759de81df60b2283d18f4da Added interface and methods to get CSS class associated to portlet container diff -r b3a4f4e2c959 -r 561b132c6f14 src/pyams_portal/interfaces/__init__.py --- 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""" diff -r b3a4f4e2c959 -r 561b132c6f14 src/pyams_portal/portlet.py --- 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 diff -r b3a4f4e2c959 -r 561b132c6f14 src/pyams_portal/templates/pagelet.pt --- 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()}">
-
+
Content
diff -r b3a4f4e2c959 -r 561b132c6f14 src/pyams_portal/views.py --- 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: