Set blog manager as skinnable content
authorThierry Florac <thierry.florac@onf.fr>
Mon, 10 Oct 2016 11:46:32 +0200
changeset 55 912cb6d5314e
parent 54 e26ea933fb8e
child 56 eecb9a1e87aa
Set blog manager as skinnable content
src/pyams_content/shared/blog/manager.py
src/pyams_content/shared/common/zmi/manager.py
--- a/src/pyams_content/shared/blog/manager.py	Tue Aug 09 17:46:17 2016 +0200
+++ b/src/pyams_content/shared/blog/manager.py	Mon Oct 10 11:46:32 2016 +0200
@@ -25,6 +25,7 @@
 # import packages
 from pyams_content.shared.blog import BlogPost
 from pyams_content.shared.common.manager import SharedTool
+from pyams_skin.skin import UserSkinnableContent
 from pyams_utils.traversing import get_parent
 from pyramid.events import subscriber
 from zope.container.folder import Folder
@@ -37,7 +38,7 @@
 
 
 @implementer(IBlogManager, IThemesManagerTarget, IAttributeAnnotatable)
-class BlogManager(SharedTool):
+class BlogManager(SharedTool, UserSkinnableContent):
     """Nlog manager class"""
 
     shared_content_type = BLOG_CONTENT_TYPE
--- a/src/pyams_content/shared/common/zmi/manager.py	Tue Aug 09 17:46:17 2016 +0200
+++ b/src/pyams_content/shared/common/zmi/manager.py	Mon Oct 10 11:46:32 2016 +0200
@@ -20,7 +20,7 @@
 from pyams_content.shared.common.interfaces import ISharedTool
 from pyams_form.interfaces.form import IWidgetForm, IFormHelp
 from pyams_i18n.interfaces import II18n, II18nManager
-from pyams_skin.interfaces import IInnerPage, IPageHeader, IContentTitle
+from pyams_skin.interfaces import IInnerPage, IPageHeader, IContentTitle, IUserSkinnable
 from pyams_skin.interfaces.viewlet import IMenuHeader, IBreadcrumbItem
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
@@ -99,7 +99,15 @@
 
     legend = _("Shared tool properties")
 
-    fields = field.Fields(ISharedTool).omit('__parent__', '__name__')
+    @property
+    def fields(self):
+        fields = field.Fields(ISharedTool).omit('__parent__', '__name__')
+        if IUserSkinnable.providedBy(self.context):
+            fields += field.Fields(IUserSkinnable)
+            if not self.getContent().can_inherit_skin:
+                fields = fields.omit('inherit_skin')
+        return fields
+
     ajax_handler = 'properties.json'
     edit_permission = MANAGE_TOOL_PERMISSION