src/pyams_content/shared/site/interfaces/__init__.py
branchdev-dc
changeset 1086 3d259e1718ef
parent 1079 a5e56749ca3d
parent 1084 6b6a884fa28a
child 1087 978a2b9123b9
equal deleted inserted replaced
1079:a5e56749ca3d 1086:3d259e1718ef
     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 ISiteContainer(IContainer, IContained, IWorkflowPublicationSupport):
       
    54     """Base site container interface"""
       
    55 
       
    56     contains(ISiteElement)
       
    57 
       
    58     def get_folders_tree(self, selected=None):
       
    59         """Get site tree in JSON format"""
       
    60 
       
    61 
       
    62 class ISiteFolder(IBaseContent, ISiteElement, ISiteContainer, ISequentialIdTarget):
       
    63     """Site folder interface
       
    64 
       
    65     A site folder is made to contain sub-folders and topics
       
    66     """
       
    67 
       
    68     heading = I18nTextField(title=_("Heading"),
       
    69                             description=_("Heading displayed according to presentation template"),
       
    70                             required=False)
       
    71 
       
    72     description = I18nTextField(title=_("Meta-description"),
       
    73                                 description=_("The folder's description is 'hidden' into HTML's page headers; but it "
       
    74                                               "can be seen, for example, in some search engines results as content's "
       
    75                                               "description; if description is empty, content's header will be used."),
       
    76                                 required=False)
       
    77 
       
    78     notepad = Text(title=_("Notepad"),
       
    79                    description=_("Internal information to be known about this content"),
       
    80                    required=False)
       
    81 
       
    82     visible_in_list = Bool(title=_("Visible in folders list"),
       
    83                            description=_("If 'no', folder will not be displayed into folders list"),
       
    84                            required=True,
       
    85                            default=True)
       
    86 
       
    87     navigation_title = I18nTextLineField(title=_("Navigation title"),
       
    88                                          description=_("Folder's title displayed in navigation pages; "
       
    89                                                        "original title will be used if none is specified"),
       
    90                                          required=False)
       
    91 
       
    92     navigation_mode = Choice(title=_("Navigation mode"),
       
    93                              description=_("Folder behaviour when navigating to folder URL"),
       
    94                              required=True,
       
    95                              vocabulary=FOLDER_DISPLAY_MODE_VOCABULARY,
       
    96                              default=FOLDER_REDIRECT_DISPLAY_MODE)
       
    97 
       
    98 
       
    99 class ISiteFolderFactory(Interface):
       
   100     """Site folder factory interface"""
       
   101 
       
   102 
       
   103 class ISiteFolderRoles(IBaseContentManagerRoles):
       
   104     """Site folder roles interface"""
       
   105 
       
   106 
       
   107 class ISiteManager(ISharedSite, ISiteContainer, IBaseSharedTool, IDeletableElement, ISequentialIdTarget):
       
   108     """Site manager interface"""
       
   109 
       
   110     contains(ISiteElement)
       
   111 
       
   112     folder_factory = Attribute("Folder factory")
       
   113 
       
   114     topic_content_type = Attribute("Topic content type")
       
   115     topic_content_factory = Attribute("Topic content factory")
       
   116 
       
   117     description = I18nTextField(title=_("Meta-description"),
       
   118                                 description=_("The site's description is 'hidden' into HTML's page headers; but it "
       
   119                                               "can be seen, for example, in some search engines results as content's "
       
   120                                               "description; if description is empty, content's header will be used."),
       
   121                                 required=False)
       
   122 
       
   123     notepad = Text(title=_("Notepad"),
       
   124                    description=_("Internal information to be known about this content"),
       
   125                    required=False)
       
   126 
       
   127 
       
   128 class ISiteManagerFactory(Interface):
       
   129     """Site manager factory interface"""
       
   130 
       
   131 
       
   132 SITE_TOPIC_CONTENT_TYPE = 'site-topic'
       
   133 SITE_TOPIC_CONTENT_NAME = _("Site topic")
       
   134 
       
   135 
       
   136 class IWfSiteTopic(IWfTopic):
       
   137     """Site topic interface"""
       
   138 
       
   139 
       
   140 class IWfSiteTopicFactory(IWfTopicFactory):
       
   141     """Topic factory interface"""
       
   142 
       
   143 
       
   144 class ISiteTopic(ITopic, ISiteElement):
       
   145     """Workflow managed site topic interface"""
       
   146 
       
   147 
       
   148 class IContentLink(ISiteElement, IInternalReference, IAttributeAnnotatable):
       
   149     """Rented content interface"""
       
   150 
       
   151     navigation_title = I18nTextLineField(title=_("Navigation title"),
       
   152                                          description=_("Alternate content's title displayed in navigation pages; "
       
   153                                                        "original title will be used if none is specified"),
       
   154                                          required=False)
       
   155 
       
   156     visible = Bool(title=_("Visible?"),
       
   157                    description=_("If 'no', link is not visible"),
       
   158                    required=True,
       
   159                    default=True)