src/pyams_content/shared/site/interfaces/__init__.py
changeset 1059 34e6d07ea2e9
parent 1058 1fe028e17f70
child 1060 29b1aaf9e080
equal deleted inserted replaced
1058:1fe028e17f70 1059:34e6d07ea2e9
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 from collections import OrderedDict
       
    16 
       
    17 from zope.annotation.interfaces import IAttributeAnnotatable
       
    18 from zope.container.constraints import containers, contains
       
    19 from zope.container.interfaces import IContained, IContainer
       
    20 from zope.interface import Attribute, Interface
       
    21 from zope.schema import Bool, Choice, Text
       
    22 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
       
    23 
       
    24 from pyams_content import _
       
    25 from pyams_content.interfaces import IBaseContent
       
    26 from pyams_content.shared.common.interfaces import IBaseContentManagerRoles, IBaseSharedTool, IDeletableElement, \
       
    27     ISharedSite
       
    28 from pyams_content.shared.topic.interfaces import ITopic, IWfTopic, IWfTopicFactory
       
    29 from pyams_i18n.schema import I18nTextField, I18nTextLineField
       
    30 from pyams_sequence.interfaces import IInternalReference, ISequentialIdTarget
       
    31 from pyams_workflow.interfaces import IWorkflowPublicationSupport
       
    32 
       
    33 
       
    34 FOLDER_REDIRECT_DISPLAY_MODE = 'redirect'
       
    35 FOLDER_TEMPLATE_DISPLAY_MODE = 'template'
       
    36 
       
    37 FOLDER_DISPLAY_MODES = OrderedDict((
       
    38     (FOLDER_REDIRECT_DISPLAY_MODE, _("Redirect to first visible sub-folder or content")),
       
    39     (FOLDER_TEMPLATE_DISPLAY_MODE, _("Use presentation template"))
       
    40 ))
       
    41 
       
    42 FOLDER_DISPLAY_MODE_VOCABULARY = SimpleVocabulary([SimpleTerm(v, title=t) for v, t in FOLDER_DISPLAY_MODES.items()])
       
    43 
       
    44 
       
    45 class ISiteElement(IContained, IDeletableElement):
       
    46     """Base site element interface"""
       
    47 
       
    48     containers('.ISiteContainer')
       
    49 
       
    50     content_name = Attribute("Content name")
       
    51 
       
    52 
       
    53 class ISiteElementNavigation(Interface):
       
    54     """Site element navigation interface"""
       
    55 
       
    56     visible = Attribute("Visible element?")
       
    57 
       
    58 
       
    59 class ISiteContainer(IContainer, IContained, IWorkflowPublicationSupport):
       
    60     """Base site container interface"""
       
    61 
       
    62     contains(ISiteElement)
       
    63 
       
    64     def get_visible_items(self, request=None):
       
    65         """Iterator over container visible items"""
       
    66 
       
    67     def get_folders_tree(self, selected=None):
       
    68         """Get site tree in JSON format"""
       
    69 
       
    70 
       
    71 class ISiteFolder(IBaseContent, ISiteElement, ISiteContainer, ISequentialIdTarget):
       
    72     """Site folder interface
       
    73 
       
    74     A site folder is made to contain sub-folders and topics
       
    75     """
       
    76 
       
    77     header = I18nTextField(title=_("Header"),
       
    78                            description=_("Heading displayed according to presentation template"),
       
    79                            required=False)
       
    80 
       
    81     description = I18nTextField(title=_("Meta-description"),
       
    82                                 description=_("The folder's description is 'hidden' into HTML's page headers; but it "
       
    83                                               "can be seen, for example, in some search engines results as content's "
       
    84                                               "description; if description is empty, content's header will be used."),
       
    85                                 required=False)
       
    86 
       
    87     notepad = Text(title=_("Notepad"),
       
    88                    description=_("Internal information to be known about this content"),
       
    89                    required=False)
       
    90 
       
    91     visible_in_list = Bool(title=_("Visible in folders list"),
       
    92                            description=_("If 'no', folder will not be displayed into folders list"),
       
    93                            required=True,
       
    94                            default=True)
       
    95 
       
    96     navigation_title = I18nTextLineField(title=_("Navigation title"),
       
    97                                          description=_("Folder's title displayed in navigation pages; "
       
    98                                                        "original title will be used if none is specified"),
       
    99                                          required=False)
       
   100 
       
   101     navigation_mode = Choice(title=_("Navigation mode"),
       
   102                              description=_("Folder behaviour when navigating to folder URL"),
       
   103                              required=True,
       
   104                              vocabulary=FOLDER_DISPLAY_MODE_VOCABULARY,
       
   105                              default=FOLDER_REDIRECT_DISPLAY_MODE)
       
   106 
       
   107 
       
   108 class ISiteFolderFactory(Interface):
       
   109     """Site folder factory interface"""
       
   110 
       
   111 
       
   112 class ISiteFolderRoles(IBaseContentManagerRoles):
       
   113     """Site folder roles interface"""
       
   114 
       
   115 
       
   116 class ISiteManager(ISharedSite, ISiteContainer, IBaseSharedTool, IDeletableElement, ISequentialIdTarget):
       
   117     """Site manager interface"""
       
   118 
       
   119     contains(ISiteElement)
       
   120 
       
   121     folder_factory = Attribute("Folder factory")
       
   122 
       
   123     topic_content_type = Attribute("Topic content type")
       
   124     topic_content_factory = Attribute("Topic content factory")
       
   125 
       
   126     description = I18nTextField(title=_("Meta-description"),
       
   127                                 description=_("The site's description is 'hidden' into HTML's page headers; but it "
       
   128                                               "can be seen, for example, in some search engines results as content's "
       
   129                                               "description; if description is empty, content's header will be used."),
       
   130                                 required=False)
       
   131 
       
   132     notepad = Text(title=_("Notepad"),
       
   133                    description=_("Internal information to be known about this content"),
       
   134                    required=False)
       
   135 
       
   136 
       
   137 class ISiteManagerFactory(Interface):
       
   138     """Site manager factory interface"""
       
   139 
       
   140 
       
   141 SITE_TOPIC_CONTENT_TYPE = 'site-topic'
       
   142 SITE_TOPIC_CONTENT_NAME = _("Site topic")
       
   143 
       
   144 
       
   145 class IWfSiteTopic(IWfTopic):
       
   146     """Site topic interface"""
       
   147 
       
   148 
       
   149 class IWfSiteTopicFactory(IWfTopicFactory):
       
   150     """Topic factory interface"""
       
   151 
       
   152 
       
   153 class ISiteTopic(ITopic, ISiteElement):
       
   154     """Workflow managed site topic interface"""
       
   155 
       
   156 
       
   157 class IContentLink(ISiteElement, IInternalReference, IAttributeAnnotatable):
       
   158     """Rented content interface"""
       
   159 
       
   160     navigation_title = I18nTextLineField(title=_("Navigation title"),
       
   161                                          description=_("Alternate content's title displayed in navigation pages; "
       
   162                                                        "original title will be used if none is specified"),
       
   163                                          required=False)
       
   164 
       
   165     visible = Bool(title=_("Visible?"),
       
   166                    description=_("If 'no', link is not visible"),
       
   167                    required=True,
       
   168                    default=True)
       
   169 
       
   170 
       
   171 class IContentSummaryInfo(Interface):
       
   172     """Content interface for site summary page"""
       
   173 
       
   174     context = Attribute("Link to adapted context")
       
   175 
       
   176     title = Attribute("Content's title")
       
   177 
       
   178     header = Attribute("Header")
       
   179 
       
   180     button_title = Attribute("Button's target")