Added description and notepad to sites, folders and blogs
authorThierry Florac <tflorac@ulthar.net>
Wed, 19 Sep 2018 16:00:08 +0200
changeset 963 fff756709617
parent 962 7bff93e41787
child 964 ca1064e94ad2
Added description and notepad to sites, folders and blogs
src/pyams_content/shared/blog/interfaces/__init__.py
src/pyams_content/shared/blog/manager.py
src/pyams_content/shared/blog/zmi/manager.py
src/pyams_content/shared/common/interfaces/__init__.py
src/pyams_content/shared/site/folder.py
src/pyams_content/shared/site/interfaces/__init__.py
src/pyams_content/shared/site/manager.py
src/pyams_content/shared/site/zmi/folder.py
src/pyams_content/shared/site/zmi/manager.py
--- a/src/pyams_content/shared/blog/interfaces/__init__.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/blog/interfaces/__init__.py	Wed Sep 19 16:00:08 2018 +0200
@@ -12,19 +12,16 @@
 
 __docformat__ = 'restructuredtext'
 
+from zope.container.constraints import containers, contains
+from zope.container.interfaces import IContainer
+from zope.interface import Attribute, Interface
+from zope.schema import Text
 
-# import standard library
-
-# import interfaces
 from pyams_content.shared.common.interfaces import ISharedSite, IBaseSharedTool, ISharedContent, \
     IDeletableElement, IWfSharedContentPortalContext
+from pyams_i18n.schema import I18nTextField
 from pyams_sequence.interfaces import ISequentialIdTarget
 from pyams_workflow.interfaces import IWorkflowPublicationSupport
-from zope.container.interfaces import IContainer
-
-# import packages
-from zope.container.constraints import containers, contains
-from zope.interface import Attribute, Interface
 
 from pyams_content import _
 
@@ -68,6 +65,16 @@
     topic_content_type = Attribute("Topic content type")
     topic_content_factory = Attribute("Topic content factory")
 
+    description = I18nTextField(title=_("Meta-description"),
+                                description=_("The blog's description is 'hidden' into HTML's page headers; but it "
+                                              "can be seen, for example, in some search engines results as content's "
+                                              "description; if description is empty, content's header will be used."),
+                                required=False)
+
+    notepad = Text(title=_("Notepad"),
+                   description=_("Internal information to be known about this content"),
+                   required=False)
+
 
 class IBlogManagerFactory(Interface):
     """Blog manager factory interface"""
--- a/src/pyams_content/shared/blog/manager.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/blog/manager.py	Wed Sep 19 16:00:08 2018 +0200
@@ -12,10 +12,13 @@
 
 __docformat__ = 'restructuredtext'
 
+from pyramid.events import subscriber
+from zope.component.interfaces import ISite
+from zope.container.folder import Folder
+from zope.interface import implementer
+from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectRemovedEvent
+from zope.schema.fieldproperty import FieldProperty
 
-# import standard library
-
-# import interfaces
 from pyams_content.component.illustration import IIllustrationTarget, ILinkIllustrationTarget
 from pyams_content.component.paragraph.interfaces import IParagraphFactorySettings
 from pyams_content.component.theme.interfaces import IThemesManagerTarget
@@ -24,22 +27,14 @@
 from pyams_content.features.preview.interfaces import IPreviewTarget
 from pyams_content.reference.pictograms.interfaces import IPictogramManagerTarget
 from pyams_content.root.interfaces import ISiteRoot
+from pyams_content.shared.blog import BlogPost
 from pyams_content.shared.blog.interfaces import IBlogManager, IBlogFolder, IBlogFolderFactory, IBlogManagerFactory
 from pyams_content.shared.common.interfaces import ISharedContentFactory
+from pyams_content.shared.common.manager import BaseSharedTool
 from pyams_portal.interfaces import IPortalContext
-from zope.component.interfaces import ISite
-from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectRemovedEvent
-
-# import packages
-from pyams_content.shared.blog import BlogPost
-from pyams_content.shared.common.manager import BaseSharedTool
 from pyams_skin.skin import UserSkinnableContent
 from pyams_utils.adapter import adapter_config
 from pyams_utils.traversing import get_parent
-from pyramid.events import subscriber
-from zope.container.folder import Folder
-from zope.interface import implementer
-from zope.schema.fieldproperty import FieldProperty
 
 
 @implementer(IBlogFolder)
@@ -58,6 +53,9 @@
 class BlogManager(Folder, BaseSharedTool, UserSkinnableContent):
     """Nlog manager class"""
 
+    description = FieldProperty(IBlogManager['description'])
+    notepad = FieldProperty(IBlogManager['notepad'])
+
     allowed_paragraphs = FieldProperty(IParagraphFactorySettings['allowed_paragraphs'])
     auto_created_paragraphs = FieldProperty(IParagraphFactorySettings['auto_created_paragraphs'])
 
--- a/src/pyams_content/shared/blog/zmi/manager.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/blog/zmi/manager.py	Wed Sep 19 16:00:08 2018 +0200
@@ -12,28 +12,27 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
 from datetime import datetime
 
-# import interfaces
-from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION, MANAGE_SITE_PERMISSION
+from pyramid.events import subscriber
+from pyramid.path import DottedNameResolver
+from z3c.form import field
+from z3c.form.interfaces import IDataExtractedEvent
+from zope.interface import Invalid
+
+from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION, MANAGE_SITE_PERMISSION, MANAGE_TOOL_PERMISSION
 from pyams_content.root.interfaces import ISiteRoot
 from pyams_content.shared.blog.interfaces import IBlogManager, IBlogManagerFactory
+from pyams_content.shared.blog.manager import BlogManager
+from pyams_content.shared.common import IBaseSharedTool
+from pyams_content.shared.common.zmi.manager import SharedToolPropertiesEditForm
 from pyams_content.skin.zmi.interfaces import ISiteTreeTable, IUserAddingsMenuLabel
+from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_i18n.interfaces import II18n, INegotiator
+from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.interfaces.container import ITableElementEditor
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, ITableItemColumnActionsMenu, IMenuHeader
 from pyams_skin.layer import IPyAMSLayer
-from pyams_workflow.interfaces import IWorkflowPublicationInfo
-from pyams_zmi.interfaces.menu import IPropertiesMenu, ISiteManagementMenu
-from pyams_zmi.layer import IAdminLayer
-from z3c.form.interfaces import IDataExtractedEvent
-
-# import packages
-from pyams_content.shared.blog.manager import BlogManager
-from pyams_form.form import AJAXAddForm, ajax_config
-from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.table import DefaultElementEditorAdapter
 from pyams_skin.viewlet.menu import MenuItem
 from pyams_skin.viewlet.toolbar import ToolbarMenuItem
@@ -43,11 +42,10 @@
 from pyams_utils.unicode import translate_string
 from pyams_utils.url import absolute_url
 from pyams_viewlet.viewlet import viewlet_config
+from pyams_workflow.interfaces import IWorkflowPublicationInfo
 from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
-from pyramid.events import subscriber
-from pyramid.path import DottedNameResolver
-from z3c.form import field
-from zope.interface import Invalid
+from pyams_zmi.interfaces.menu import IPropertiesMenu, ISiteManagementMenu
+from pyams_zmi.layer import IAdminLayer
 
 from pyams_content import _
 
@@ -142,6 +140,17 @@
     modal_target = False
 
 
+@pagelet_config(name='properties.html', context=IBlogManager, layer=IPyAMSLayer, permission=MANAGE_TOOL_PERMISSION)
+@ajax_config(name='properties.json', context=IBlogManager, layer=IPyAMSLayer)
+class BlogManagerPropertiesEditForm(SharedToolPropertiesEditForm):
+    """Site folder properties edit form"""
+
+    legend = _("Blog properties")
+
+    fields = field.Fields(IBlogManager).select('title', 'short_name', 'description', 'notepad') + \
+        field.Fields(IBaseSharedTool).select('shared_content_workflow')
+
+
 #
 # Blog manager publication views
 #
--- a/src/pyams_content/shared/common/interfaces/__init__.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/common/interfaces/__init__.py	Wed Sep 19 16:00:08 2018 +0200
@@ -12,25 +12,21 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
-
 from zope.container.constraints import containers, contains
 from zope.container.interfaces import IContainer
 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
 
+from pyams_content import _
+
 
 class IDeletableElement(Interface):
     """Deletable element interface"""
--- a/src/pyams_content/shared/site/folder.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/site/folder.py	Wed Sep 19 16:00:08 2018 +0200
@@ -12,33 +12,28 @@
 
 __docformat__ = 'restructuredtext'
 
+from zope.container.ordered import OrderedContainer
+from zope.interface import implementer
+from zope.intid.interfaces import IIntIds
+from zope.schema.fieldproperty import FieldProperty
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
-# import standard library
-
-# import interfaces
 from pyams_content.component.illustration import IIllustrationTarget, ILinkIllustrationTarget
 from pyams_content.features.preview.interfaces import IPreviewTarget
 from pyams_content.interfaces import MANAGE_SITE_PERMISSION
+from pyams_content.shared.common.manager import BaseSharedTool
+from pyams_content.shared.site.container import SiteContainerMixin
 from pyams_content.shared.site.interfaces import ISiteFolder, ISiteManager, ISiteFolderRoles
 from pyams_form.interfaces.form import IFormContextPermissionChecker
 from pyams_i18n.interfaces import II18n
 from pyams_portal.interfaces import IPortalContext
 from pyams_security.interfaces import IDefaultProtectionPolicy
-from zope.intid.interfaces import IIntIds
-
-# import packages
-from pyams_content.shared.common.manager import BaseSharedTool
-from pyams_content.shared.site.container import SiteContainerMixin
 from pyams_utils.adapter import adapter_config, ContextAdapter
 from pyams_utils.container import find_objects_providing
 from pyams_utils.registry import get_local_registry
 from pyams_utils.request import query_request
 from pyams_utils.traversing import get_parent
 from pyams_utils.vocabulary import vocabulary_config
-from zope.container.ordered import OrderedContainer
-from zope.interface import implementer
-from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from pyams_content import _
 
@@ -51,6 +46,7 @@
     roles_interface = ISiteFolderRoles
 
     heading = FieldProperty(ISiteFolder['heading'])
+    description = FieldProperty(ISiteFolder['description'])
     notepad = FieldProperty(ISiteFolder['notepad'])
 
     visible_in_list = FieldProperty(ISiteFolder['visible_in_list'])
--- a/src/pyams_content/shared/site/interfaces/__init__.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/site/interfaces/__init__.py	Wed Sep 19 16:00:08 2018 +0200
@@ -12,25 +12,21 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
 from collections import OrderedDict
 
-# import interfaces
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.container.constraints import containers, contains
+from zope.container.interfaces import IContainer, IContained
+from zope.interface import Interface, Attribute
+from zope.schema import Text, Bool, Choice
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+
 from pyams_content.interfaces import IBaseContent
-from pyams_sequence.interfaces import ISequentialIdTarget, IInternalReference
-from pyams_workflow.interfaces import IWorkflowPublicationSupport
-from zope.annotation.interfaces import IAttributeAnnotatable
-from zope.container.interfaces import IContainer, IContained
-
-# import packages
 from pyams_content.shared.common.interfaces import ISharedSite, ISharedContent, \
     IBaseContentManagerRoles, IBaseSharedTool, IDeletableElement, IWfSharedContentPortalContext
 from pyams_i18n.schema import I18nTextLineField, I18nTextField
-from zope.container.constraints import containers, contains
-from zope.interface import Interface, Attribute
-from zope.schema import Text, Bool, Choice
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+from pyams_sequence.interfaces import ISequentialIdTarget, IInternalReference
+from pyams_workflow.interfaces import IWorkflowPublicationSupport
 
 from pyams_content import _
 
@@ -73,6 +69,12 @@
                             description=_("Heading displayed according to presentation template"),
                             required=False)
 
+    description = I18nTextField(title=_("Meta-description"),
+                                description=_("The folder's description is 'hidden' into HTML's page headers; but it "
+                                              "can be seen, for example, in some search engines results as content's "
+                                              "description; if description is empty, content's header will be used."),
+                                required=False)
+
     notepad = Text(title=_("Notepad"),
                    description=_("Internal information to be known about this content"),
                    required=False)
@@ -112,6 +114,16 @@
     topic_content_type = Attribute("Topic content type")
     topic_content_factory = Attribute("Topic content factory")
 
+    description = I18nTextField(title=_("Meta-description"),
+                                description=_("The site's description is 'hidden' into HTML's page headers; but it "
+                                              "can be seen, for example, in some search engines results as content's "
+                                              "description; if description is empty, content's header will be used."),
+                                required=False)
+
+    notepad = Text(title=_("Notepad"),
+                   description=_("Internal information to be known about this content"),
+                   required=False)
+
 
 class ISiteManagerFactory(Interface):
     """Site manager factory interface"""
--- a/src/pyams_content/shared/site/manager.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/site/manager.py	Wed Sep 19 16:00:08 2018 +0200
@@ -12,10 +12,14 @@
 
 __docformat__ = 'restructuredtext'
 
+from pyramid.events import subscriber
+from zope.component.interfaces import ISite
+from zope.container.ordered import OrderedContainer
+from zope.interface import implementer
+from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectRemovedEvent
+from zope.schema.fieldproperty import FieldProperty
+from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
 
-# import standard library
-
-# import interfaces
 from pyams_content.component.illustration import IIllustrationTarget, ILinkIllustrationTarget
 from pyams_content.component.paragraph.interfaces import IParagraphFactorySettings
 from pyams_content.component.theme.interfaces import IThemesManagerTarget
@@ -26,29 +30,20 @@
 from pyams_content.reference.pictograms.interfaces import IPictogramManagerTarget
 from pyams_content.root.interfaces import ISiteRoot
 from pyams_content.shared.common.interfaces import ISharedContentFactory
+from pyams_content.shared.common.manager import BaseSharedTool
+from pyams_content.shared.site import Topic
+from pyams_content.shared.site.container import SiteContainerMixin
+from pyams_content.shared.site.folder import SiteFolder
 from pyams_content.shared.site.interfaces import ISiteManager, ISiteManagerFactory, ISiteFolderFactory, ISiteContainer
 from pyams_form.interfaces.form import IFormContextPermissionChecker
 from pyams_i18n.interfaces import II18n
 from pyams_portal.interfaces import IPortalContext
-from zope.component.interfaces import ISite
-from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectRemovedEvent
-
-# import packages
-from pyams_content.shared.common.manager import BaseSharedTool
-from pyams_content.shared.site import Topic
-from pyams_content.shared.site.container import SiteContainerMixin
-from pyams_content.shared.site.folder import SiteFolder
 from pyams_skin.skin import UserSkinnableContent
 from pyams_utils.adapter import adapter_config, ContextAdapter
 from pyams_utils.registry import get_utilities_for
 from pyams_utils.request import query_request
 from pyams_utils.traversing import get_parent
 from pyams_utils.vocabulary import vocabulary_config
-from pyramid.events import subscriber
-from zope.container.ordered import OrderedContainer
-from zope.interface import implementer
-from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
 
 from pyams_content import _
 
@@ -59,6 +54,9 @@
 class SiteManager(SiteContainerMixin, OrderedContainer, BaseSharedTool, UserSkinnableContent):
     """Site manager persistent class"""
 
+    description = FieldProperty(ISiteManager['description'])
+    notepad = FieldProperty(ISiteManager['notepad'])
+
     allowed_paragraphs = FieldProperty(IParagraphFactorySettings['allowed_paragraphs'])
     auto_created_paragraphs = FieldProperty(IParagraphFactorySettings['auto_created_paragraphs'])
 
@@ -138,4 +136,4 @@
         request = query_request()
         super(SiteManagerVocabulary, self).__init__([SimpleTerm(v, title=II18n(t).query_attribute('title',
                                                                                                   request=request))
-                                                    for v, t in get_utilities_for(self.interface)])
+                                                     for v, t in get_utilities_for(self.interface)])
--- a/src/pyams_content/shared/site/zmi/folder.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/site/zmi/folder.py	Wed Sep 19 16:00:08 2018 +0200
@@ -184,8 +184,8 @@
 
     legend = _("Site folder properties")
 
-    fields = field.Fields(ISiteFolder).select('title', 'short_name', 'heading', 'notepad') + \
-             field.Fields(IBaseSharedTool).select('shared_content_workflow')
+    fields = field.Fields(ISiteFolder).select('title', 'short_name', 'heading', 'description', 'notepad') + \
+        field.Fields(IBaseSharedTool).select('shared_content_workflow')
 
 
 @adapter_config(name='navigation', context=(ISiteFolder, IPyAMSLayer, SiteFolderPropertiesEditForm),
--- a/src/pyams_content/shared/site/zmi/manager.py	Wed Sep 19 15:08:06 2018 +0200
+++ b/src/pyams_content/shared/site/zmi/manager.py	Wed Sep 19 16:00:08 2018 +0200
@@ -12,27 +12,26 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
+from pyramid.events import subscriber
+from pyramid.path import DottedNameResolver
+from z3c.form import field
+from z3c.form.interfaces import IDataExtractedEvent
+from zope.interface import Invalid, Interface
 
-# import interfaces
-from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION
+from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION, MANAGE_TOOL_PERMISSION
 from pyams_content.root.interfaces import ISiteRoot
+from pyams_content.shared.common import IBaseSharedTool
+from pyams_content.shared.common.zmi.manager import SharedToolPropertiesEditForm
+from pyams_content.shared.site import WfTopic
 from pyams_content.shared.site.interfaces import ISiteManager, ISiteManagerFactory
+from pyams_content.shared.site.manager import SiteManager
 from pyams_content.skin.zmi.interfaces import ISiteTreeTable, IUserAddingsMenuLabel
+from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_i18n.interfaces import II18n, INegotiator
+from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.interfaces.container import ITableElementEditor, ITableElementName
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, IBreadcrumbItem, IMenuHeader
 from pyams_skin.layer import IPyAMSLayer
-from pyams_zmi.interfaces.menu import ISiteManagementMenu
-from pyams_zmi.layer import IAdminLayer
-from z3c.form.interfaces import IDataExtractedEvent
-
-# import packages
-from pyams_content.shared.site import WfTopic
-from pyams_content.shared.site.manager import SiteManager
-from pyams_form.form import AJAXAddForm, ajax_config
-from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.table import DefaultElementEditorAdapter
 from pyams_skin.viewlet.breadcrumb import BreadcrumbAdminLayerItem
 from pyams_skin.viewlet.toolbar import ToolbarMenuItem
@@ -42,10 +41,8 @@
 from pyams_utils.url import absolute_url
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.form import AdminDialogAddForm
-from pyramid.events import subscriber
-from pyramid.path import DottedNameResolver
-from z3c.form import field
-from zope.interface import Invalid, Interface
+from pyams_zmi.interfaces.menu import ISiteManagementMenu
+from pyams_zmi.layer import IAdminLayer
 
 from pyams_content import _
 
@@ -146,6 +143,17 @@
         return absolute_url(self.context, self.request, 'site-tree.html')
 
 
+@pagelet_config(name='properties.html', context=ISiteManager, layer=IPyAMSLayer, permission=MANAGE_TOOL_PERMISSION)
+@ajax_config(name='properties.json', context=ISiteManager, layer=IPyAMSLayer)
+class SiteManagerPropertiesEditForm(SharedToolPropertiesEditForm):
+    """Site manager properties edit form"""
+
+    legend = _("Site folder properties")
+
+    fields = field.Fields(ISiteManager).select('title', 'short_name', 'description', 'notepad') + \
+        field.Fields(IBaseSharedTool).select('shared_content_workflow')
+
+
 @subscriber(IDataExtractedEvent, form_selector=SiteManagerAddForm)
 def handle_new_site_manager_data_extraction(event):
     """Handle new site manager data extraction"""