src/pyams_content/shared/site/interfaces.py
changeset 1059 34e6d07ea2e9
parent 1028 3a608029647e
child 1060 29b1aaf9e080
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/site/interfaces.py	Tue Nov 06 14:40:22 2018 +0100
@@ -0,0 +1,180 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+from collections import OrderedDict
+
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.container.constraints import containers, contains
+from zope.container.interfaces import IContained, IContainer
+from zope.interface import Attribute, Interface
+from zope.schema import Bool, Choice, Text
+from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
+
+from pyams_content import _
+from pyams_content.interfaces import IBaseContent
+from pyams_content.shared.common.interfaces import IBaseContentManagerRoles, IBaseSharedTool, IDeletableElement, \
+    ISharedSite
+from pyams_content.shared.topic.interfaces import ITopic, IWfTopic, IWfTopicFactory
+from pyams_i18n.schema import I18nTextField, I18nTextLineField
+from pyams_sequence.interfaces import IInternalReference, ISequentialIdTarget
+from pyams_workflow.interfaces import IWorkflowPublicationSupport
+
+
+FOLDER_REDIRECT_DISPLAY_MODE = 'redirect'
+FOLDER_TEMPLATE_DISPLAY_MODE = 'template'
+
+FOLDER_DISPLAY_MODES = OrderedDict((
+    (FOLDER_REDIRECT_DISPLAY_MODE, _("Redirect to first visible sub-folder or content")),
+    (FOLDER_TEMPLATE_DISPLAY_MODE, _("Use presentation template"))
+))
+
+FOLDER_DISPLAY_MODE_VOCABULARY = SimpleVocabulary([SimpleTerm(v, title=t) for v, t in FOLDER_DISPLAY_MODES.items()])
+
+
+class ISiteElement(IContained, IDeletableElement):
+    """Base site element interface"""
+
+    containers('.ISiteContainer')
+
+    content_name = Attribute("Content name")
+
+
+class ISiteElementNavigation(Interface):
+    """Site element navigation interface"""
+
+    visible = Attribute("Visible element?")
+
+
+class ISiteContainer(IContainer, IContained, IWorkflowPublicationSupport):
+    """Base site container interface"""
+
+    contains(ISiteElement)
+
+    def get_visible_items(self, request=None):
+        """Iterator over container visible items"""
+
+    def get_folders_tree(self, selected=None):
+        """Get site tree in JSON format"""
+
+
+class ISiteFolder(IBaseContent, ISiteElement, ISiteContainer, ISequentialIdTarget):
+    """Site folder interface
+
+    A site folder is made to contain sub-folders and topics
+    """
+
+    header = I18nTextField(title=_("Header"),
+                           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)
+
+    visible_in_list = Bool(title=_("Visible in folders list"),
+                           description=_("If 'no', folder will not be displayed into folders list"),
+                           required=True,
+                           default=True)
+
+    navigation_title = I18nTextLineField(title=_("Navigation title"),
+                                         description=_("Folder's title displayed in navigation pages; "
+                                                       "original title will be used if none is specified"),
+                                         required=False)
+
+    navigation_mode = Choice(title=_("Navigation mode"),
+                             description=_("Folder behaviour when navigating to folder URL"),
+                             required=True,
+                             vocabulary=FOLDER_DISPLAY_MODE_VOCABULARY,
+                             default=FOLDER_REDIRECT_DISPLAY_MODE)
+
+
+class ISiteFolderFactory(Interface):
+    """Site folder factory interface"""
+
+
+class ISiteFolderRoles(IBaseContentManagerRoles):
+    """Site folder roles interface"""
+
+
+class ISiteManager(ISharedSite, ISiteContainer, IBaseSharedTool, IDeletableElement, ISequentialIdTarget):
+    """Site manager interface"""
+
+    contains(ISiteElement)
+
+    folder_factory = Attribute("Folder factory")
+
+    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"""
+
+
+SITE_TOPIC_CONTENT_TYPE = 'site-topic'
+SITE_TOPIC_CONTENT_NAME = _("Site topic")
+
+
+class IWfSiteTopic(IWfTopic):
+    """Site topic interface"""
+
+
+class IWfSiteTopicFactory(IWfTopicFactory):
+    """Topic factory interface"""
+
+
+class ISiteTopic(ITopic, ISiteElement):
+    """Workflow managed site topic interface"""
+
+
+class IContentLink(ISiteElement, IInternalReference, IAttributeAnnotatable):
+    """Rented content interface"""
+
+    navigation_title = I18nTextLineField(title=_("Navigation title"),
+                                         description=_("Alternate content's title displayed in navigation pages; "
+                                                       "original title will be used if none is specified"),
+                                         required=False)
+
+    visible = Bool(title=_("Visible?"),
+                   description=_("If 'no', link is not visible"),
+                   required=True,
+                   default=True)
+
+
+class IContentSummaryInfo(Interface):
+    """Content interface for site summary page"""
+
+    context = Attribute("Link to adapted context")
+
+    title = Attribute("Content's title")
+
+    header = Attribute("Header")
+
+    button_title = Attribute("Button's target")