Added static attribute to disable header on selected shared contents
authorThierry Florac <thierry.florac@onf.fr>
Tue, 04 Sep 2018 11:03:25 +0200
changeset 919 45ff6cd59fe0
parent 918 975dba68ebd5
child 920 d7cb90448d3e
Added static attribute to disable header on selected shared contents
src/pyams_content/shared/common/__init__.py
src/pyams_content/shared/common/interfaces/__init__.py
src/pyams_content/shared/common/zmi/properties.py
src/pyams_content/shared/form/__init__.py
src/pyams_content/shared/form/interfaces/__init__.py
src/pyams_content/shared/imagemap/__init__.py
src/pyams_content/shared/logo/__init__.py
src/pyams_content/shared/view/__init__.py
--- a/src/pyams_content/shared/common/__init__.py	Tue Sep 04 09:23:57 2018 +0200
+++ b/src/pyams_content/shared/common/__init__.py	Tue Sep 04 11:03:25 2018 +0200
@@ -17,47 +17,46 @@
 
 # import interfaces
 from hypatia.interfaces import ICatalog
+# import packages
+from persistent import Persistent
+from pyramid.events import subscriber
+from pyramid.interfaces import IWSGIApplicationCreatedEvent
+from pyramid.settings import asbool
+from pyramid.threadlocal import get_current_registry
+from zope.container.contained import Contained
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.interface import implementer
+from zope.intid.interfaces import IIntIds
+from zope.lifecycleevent.interfaces import IObjectModifiedEvent
+from zope.schema.fieldproperty import FieldProperty
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+
+from pyams_content import _
+from pyams_content.features.checker import BaseContentChecker
+from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE, ERROR_VALUE
+from pyams_content.features.review.interfaces import IReviewComments
 from pyams_content.interfaces import IBaseContentInfo, OWNER_ROLE, MANAGER_ROLE, CONTRIBUTOR_ROLE, READER_ROLE, \
     GUEST_ROLE
-from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE, ERROR_VALUE
-from pyams_content.features.review.interfaces import IReviewComments
 from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedContent, \
     IBaseSharedTool, ISharedSite, IWfSharedContentFactory, CONTENT_TYPES_VOCABULARY
+from pyams_i18n.content import I18nManagerMixin
 from pyams_i18n.interfaces import II18nManager, II18n
 from pyams_portal.interfaces import DESIGNER_ROLE
 from pyams_security.interfaces import IDefaultProtectionPolicy
-from pyams_sequence.interfaces import ISequentialIdTarget, ISequentialIdInfo
-from pyams_utils.interfaces import VIEW_PERMISSION
-from pyams_workflow.interfaces import IWorkflowPublicationSupport, IWorkflow, IObjectClonedEvent, IWorkflowVersions
-from pyramid.interfaces import IWSGIApplicationCreatedEvent
-from zope.dublincore.interfaces import IZopeDublinCore
-from zope.intid.interfaces import IIntIds
-from zope.lifecycleevent.interfaces import IObjectModifiedEvent
-
-# import packages
-from persistent import Persistent
-from pyams_content.features.checker import BaseContentChecker
-from pyams_i18n.content import I18nManagerMixin
 from pyams_security.property import RolePrincipalsFieldProperty
 from pyams_security.security import ProtectedObject
 from pyams_security.utility import get_principal
+from pyams_sequence.interfaces import ISequentialIdTarget, ISequentialIdInfo
 from pyams_utils.adapter import adapter_config, ContextAdapter
 from pyams_utils.date import format_datetime
+from pyams_utils.interfaces import VIEW_PERMISSION
 from pyams_utils.property import classproperty, classproperty_support
 from pyams_utils.registry import query_utility, get_utilities_for
 from pyams_utils.request import query_request, check_request
 from pyams_utils.timezone import tztime
 from pyams_utils.traversing import get_parent
 from pyams_utils.vocabulary import vocabulary_config
-from pyramid.events import subscriber
-from pyramid.settings import asbool
-from pyramid.threadlocal import get_current_registry
-from zope.container.contained import Contained
-from zope.interface import implementer
-from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
-
-from pyams_content import _
+from pyams_workflow.interfaces import IWorkflowPublicationSupport, IWorkflow, IObjectClonedEvent, IWorkflowVersions
 
 
 @vocabulary_config(name='PyAMS shared sites')
@@ -128,6 +127,8 @@
     content_type = None
     content_name = None
 
+    handle_header = True
+
     title = FieldProperty(IWfSharedContent['title'])
     short_name = FieldProperty(IWfSharedContent['short_name'])
     content_url = FieldProperty(IWfSharedContent['content_url'])
--- a/src/pyams_content/shared/common/interfaces/__init__.py	Tue Sep 04 09:23:57 2018 +0200
+++ b/src/pyams_content/shared/common/interfaces/__init__.py	Tue Sep 04 11:03:25 2018 +0200
@@ -15,22 +15,21 @@
 
 # import standard library
 
-# import interfaces
-from pyams_content.interfaces import IBaseContent, MANAGE_CONTENT_PERMISSION, OWNER_ROLE, MANAGER_ROLE, \
-    READER_ROLE, GUEST_ROLE, WEBMASTER_ROLE, PILOT_ROLE, CONTRIBUTOR_ROLE
-from pyams_portal.interfaces import IPortalContext, DESIGNER_ROLE
-from pyams_workflow.interfaces import IWorkflowManagedContent
+from zope.container.constraints import containers, contains
 from zope.container.interfaces import IContainer
-
-# import packages
-from pyams_i18n.schema import I18nTextField
-from pyams_security.schema import Principal, PrincipalsSet
-from pyams_utils.schema import TextLineListField
-from zope.container.constraints import containers, contains
 from zope.interface import Interface, Attribute
 from zope.schema import Choice, Bool, Text, TextLine
 
 from pyams_content import _
+# import interfaces
+from pyams_content.interfaces import IBaseContent, MANAGE_CONTENT_PERMISSION, OWNER_ROLE, MANAGER_ROLE, \
+    READER_ROLE, GUEST_ROLE, WEBMASTER_ROLE, PILOT_ROLE, CONTRIBUTOR_ROLE
+# import packages
+from pyams_i18n.schema import I18nTextField
+from pyams_portal.interfaces import IPortalContext, DESIGNER_ROLE
+from pyams_security.schema import Principal, PrincipalsSet
+from pyams_utils.schema import TextLineListField
+from pyams_workflow.interfaces import IWorkflowManagedContent
 
 
 class IDeletableElement(Interface):
@@ -155,6 +154,8 @@
                            description=_("Content's header is generally displayed in page header"),
                            required=False)
 
+    handle_header = Attribute("Static boolean value to specify if header is supported by this content type")
+
     description = I18nTextField(title=_("Meta-description"),
                                 description=_("The content's description is 'hidden' into HTML's page headers; but it "
                                               "can be seen, for example, in some search engines results as content's "
--- a/src/pyams_content/shared/common/zmi/properties.py	Tue Sep 04 09:23:57 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/properties.py	Tue Sep 04 11:03:25 2018 +0200
@@ -15,35 +15,34 @@
 
 # import standard library
 
+from pyramid.events import subscriber
+from z3c.form import field
+from z3c.form.interfaces import IDataExtractedEvent, HIDDEN_MODE
+from zope.interface import implementer
+
+from pyams_content import _
 # import interfaces
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION, IBaseContent
 from pyams_content.shared.common.interfaces import IWfSharedContent
-from pyams_form.interfaces.form import IWidgetForm
-from pyams_skin.interfaces import IInnerPage, IPageHeader
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_zmi.interfaces import IPropertiesEditForm
-from pyams_zmi.interfaces.menu import IContentManagementMenu, IPropertiesMenu
-from pyams_zmi.layer import IAdminLayer
-from z3c.form.interfaces import IDataExtractedEvent, HIDDEN_MODE
-
 # import packages
 from pyams_content.shared.common.zmi import WfSharedContentHeaderAdapter
 from pyams_form.form import ajax_config
+from pyams_form.interfaces.form import IWidgetForm
 from pyams_i18n.widget import I18nSEOTextLineFieldWidget
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.event import get_json_widget_refresh_event
+from pyams_skin.interfaces import IInnerPage, IPageHeader
+from pyams_skin.layer import IPyAMSLayer
 from pyams_skin.viewlet.menu import MenuItem
 from pyams_utils.adapter import adapter_config
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
 from pyams_utils.url import generate_url
 from pyams_viewlet.manager import viewletmanager_config
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.form import AdminEditForm
-from pyramid.events import subscriber
-from z3c.form import field
-from zope.interface import implementer
-
-from pyams_content import _
+from pyams_zmi.interfaces import IPropertiesEditForm
+from pyams_zmi.interfaces.menu import IContentManagementMenu, IPropertiesMenu
+from pyams_zmi.layer import IAdminLayer
 
 
 #
@@ -82,9 +81,14 @@
 
     legend = _("Content properties")
 
-    fields = field.Fields(IWfSharedContent).select('title', 'short_name', 'content_url',
-                                                   'header', 'description', 'notepad')
-    fields['title'].widgetFactory = I18nSEOTextLineFieldWidget
+    @property
+    def fields(self):
+        fields = field.Fields(IWfSharedContent).select('title', 'short_name', 'content_url',
+                                                       'header', 'description', 'notepad')
+        fields['title'].widgetFactory = I18nSEOTextLineFieldWidget
+        if not self.context.handle_header:
+            fields = fields.omit('header')
+        return fields
 
     def updateWidgets(self, prefix=None):
         super(SharedContentPropertiesEditForm, self).updateWidgets(prefix)
--- a/src/pyams_content/shared/form/__init__.py	Tue Sep 04 09:23:57 2018 +0200
+++ b/src/pyams_content/shared/form/__init__.py	Tue Sep 04 11:03:25 2018 +0200
@@ -15,22 +15,21 @@
 
 # import standard library
 
+from zope.interface import implementer, provider, alsoProvides, noLongerProvides
+from zope.schema.fieldproperty import FieldProperty
+
+from pyams_content import _
 # import interfaces
 from pyams_content.features.checker.interfaces import IContentChecker, ERROR_VALUE
 from pyams_content.features.preview.interfaces import IPreviewTarget
 from pyams_content.features.review.interfaces import IReviewTarget
-from pyams_content.shared.form.interfaces import IWfForm, IForm, FORM_CONTENT_TYPE, FORM_CONTENT_NAME, \
-    IFormFieldContainerTarget, IFormHandler, IFormFieldContainer, IWfFormFactory
-
 # import packages
 from pyams_content.shared.common import WfSharedContent, SharedContent, register_content_type, WfSharedContentChecker, \
     IWfSharedContentFactory
+from pyams_content.shared.form.interfaces import IWfForm, IForm, FORM_CONTENT_TYPE, FORM_CONTENT_NAME, \
+    IFormFieldContainerTarget, IFormHandler, IFormFieldContainer, IWfFormFactory
 from pyams_utils.adapter import adapter_config
 from pyams_utils.registry import get_global_registry
-from zope.interface import implementer, provider, alsoProvides, noLongerProvides
-from zope.schema.fieldproperty import FieldProperty
-
-from pyams_content import _
 
 
 @implementer(IWfForm, IFormFieldContainerTarget,
@@ -42,7 +41,6 @@
     content_name = FORM_CONTENT_NAME
 
     user_title = FieldProperty(IWfForm['user_title'])
-    header = FieldProperty(IWfForm['header'])
     _handler = FieldProperty(IWfForm['handler'])
     auth_only = FieldProperty(IWfForm['auth_only'])
     use_captcha = FieldProperty(IWfForm['use_captcha'])
--- a/src/pyams_content/shared/form/interfaces/__init__.py	Tue Sep 04 09:23:57 2018 +0200
+++ b/src/pyams_content/shared/form/interfaces/__init__.py	Tue Sep 04 11:03:25 2018 +0200
@@ -15,21 +15,19 @@
 
 # import standard library
 
-# import interfaces
-from pyams_content.shared.common.interfaces import ISharedContent, IWfSharedContentPortalContext, \
-    ISharedToolPortalContext
 from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.container.constraints import containers, contains
 from zope.container.interfaces import IContainer, IContained
-
-# import packages
-from pyams_i18n.schema import I18nTextLineField, I18nTextField
-from pyams_utils.schema import MailAddressField, TextLineListField
-from zope.container.constraints import containers, contains
 from zope.interface import Interface, Attribute
 from zope.schema import TextLine, Choice, Bool
 
 from pyams_content import _
-
+# import interfaces
+from pyams_content.shared.common.interfaces import ISharedContent, IWfSharedContentPortalContext, \
+    ISharedToolPortalContext
+# import packages
+from pyams_i18n.schema import I18nTextLineField, I18nTextField
+from pyams_utils.schema import MailAddressField, TextLineListField
 
 FORM_CONTENT_TYPE = 'form'
 FORM_CONTENT_NAME = _('Form')
@@ -122,9 +120,6 @@
     user_title = I18nTextLineField(title=_("Form title"),
                                    required=True)
 
-    header = I18nTextField(title=_("Form header"),
-                           required=False)
-
     handler = Choice(title=_("Form handler"),
                      description=_("Select how form data is transmitted"),
                      vocabulary='PyAMS form handlers')
--- a/src/pyams_content/shared/imagemap/__init__.py	Tue Sep 04 09:23:57 2018 +0200
+++ b/src/pyams_content/shared/imagemap/__init__.py	Tue Sep 04 11:03:25 2018 +0200
@@ -16,7 +16,17 @@
 # import standard library
 from persistent import Persistent
 from persistent.mapping import PersistentMapping
+from pyramid.threadlocal import get_current_registry
+from z3c.form.interfaces import NOT_CHANGED
+from zope.container.contained import Contained
+from zope.interface import implementer, provider
+from zope.lifecycleevent import ObjectModifiedEvent
+from zope.location import locate
+from zope.location.interfaces import ISublocations
+from zope.schema.fieldproperty import FieldProperty
+from zope.traversing.interfaces import ITraversable
 
+from pyams_content import _
 # import interfaces
 from pyams_content.component.association.interfaces import IAssociationContainer
 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget
@@ -24,26 +34,14 @@
 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE, ERROR_VALUE
 from pyams_content.features.preview.interfaces import IPreviewTarget
 from pyams_content.features.review.interfaces import IReviewTarget
-from pyams_content.shared.imagemap.interfaces import IMAGEMAP_CONTENT_TYPE, IMAGEMAP_CONTENT_NAME, \
-    IWfImageMap, IImageMap, IImageMapArea, IWfImageMapFactory
-from pyams_i18n.interfaces import II18n, II18nManager
-from z3c.form.interfaces import NOT_CHANGED
-from zope.location.interfaces import ISublocations
-from zope.traversing.interfaces import ITraversable
-
 # import packages
 from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent, WfSharedContentChecker, \
     IWfSharedContentFactory
+from pyams_content.shared.imagemap.interfaces import IMAGEMAP_CONTENT_TYPE, IMAGEMAP_CONTENT_NAME, \
+    IWfImageMap, IImageMap, IImageMapArea, IWfImageMapFactory
+from pyams_i18n.interfaces import II18n, II18nManager
 from pyams_i18n.property import I18nFileProperty
 from pyams_utils.adapter import adapter_config, ContextAdapter
-from pyramid.threadlocal import get_current_registry
-from zope.container.contained import Contained
-from zope.interface import implementer, provider
-from zope.lifecycleevent import ObjectModifiedEvent
-from zope.location import locate
-from zope.schema.fieldproperty import FieldProperty
-
-from pyams_content import _
 
 
 @implementer(IImageMapArea)
@@ -63,6 +61,8 @@
     content_type = IMAGEMAP_CONTENT_TYPE
     content_name = IMAGEMAP_CONTENT_NAME
 
+    handle_header = False
+
     _image = I18nFileProperty(IWfImageMap['image'])
     areas = FieldProperty(IWfImageMap['areas'])
 
--- a/src/pyams_content/shared/logo/__init__.py	Tue Sep 04 09:23:57 2018 +0200
+++ b/src/pyams_content/shared/logo/__init__.py	Tue Sep 04 11:03:25 2018 +0200
@@ -15,20 +15,19 @@
 
 # import standard library
 
-# import interfaces
-from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE
-from pyams_content.shared.logo.interfaces import IWfLogo, LOGO_CONTENT_TYPE, LOGO_CONTENT_NAME, ILogo, IWfLogoFactory
-from pyams_content.features.review import IReviewTarget
-
-# import packages
-from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent, WfSharedContentChecker, \
-    IWfSharedContentFactory
-from pyams_file.property import FileProperty
-from pyams_utils.adapter import adapter_config
 from zope.interface import implementer, provider
 from zope.schema.fieldproperty import FieldProperty
 
 from pyams_content import _
+# import interfaces
+from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE
+from pyams_content.features.review import IReviewTarget
+# import packages
+from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent, WfSharedContentChecker, \
+    IWfSharedContentFactory
+from pyams_content.shared.logo.interfaces import IWfLogo, LOGO_CONTENT_TYPE, LOGO_CONTENT_NAME, ILogo, IWfLogoFactory
+from pyams_file.property import FileProperty
+from pyams_utils.adapter import adapter_config
 
 
 @implementer(IWfLogo, IReviewTarget)
@@ -38,6 +37,8 @@
     content_type = LOGO_CONTENT_TYPE
     content_name = LOGO_CONTENT_NAME
 
+    handle_header = False
+
     image = FileProperty(IWfLogo['image'])
     monochrome_image = FileProperty(IWfLogo['monochrome_image'])
     url = FieldProperty(IWfLogo['url'])
--- a/src/pyams_content/shared/view/__init__.py	Tue Sep 04 09:23:57 2018 +0200
+++ b/src/pyams_content/shared/view/__init__.py	Tue Sep 04 11:03:25 2018 +0200
@@ -9,7 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
 
 __docformat__ = 'restructuredtext'
 
@@ -25,6 +24,7 @@
 from hypatia.interfaces import ICatalog
 from pyams_content.features.preview.interfaces import IPreviewTarget
 from pyams_content.features.review.interfaces import IReviewTarget
+from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
 from pyams_content.shared.view.interfaces import IView, IWfView, IWfViewFactory, IViewQuery, \
     IViewQueryParamsExtension, IViewQueryFilterExtension, VIEW_CONTENT_TYPE, VIEW_CONTENT_NAME, IViewSettings
 from pyams_utils.interfaces import ICacheKeyValue
@@ -64,6 +64,8 @@
     content_type = VIEW_CONTENT_TYPE
     content_name = VIEW_CONTENT_NAME
 
+    handle_header = False
+
     select_context_type = FieldProperty(IWfView['select_context_type'])
     selected_content_types = FieldProperty(IWfView['selected_content_types'])
     select_context_datatype = FieldProperty(IWfView['select_context_datatype'])