src/pyams_content/shared/site/skin/folder.py
changeset 1064 2375abafdeb1
parent 1063 1f8629465141
child 1065 50612c78ed2a
equal deleted inserted replaced
1063:1f8629465141 1064:2375abafdeb1
     1 #
       
     2 # Copyright (c) 2008-2018 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 pyams_content.shared.site import ISiteElementNavigation
       
    16 from pyams_content.shared.site.interfaces import ISiteFolder, IContentSummaryInfo
       
    17 from pyams_i18n.interfaces import II18n
       
    18 from pyams_skin.layer import IPyAMSUserLayer
       
    19 from pyams_utils.adapter import adapter_config, ContextRequestAdapter
       
    20 from pyams_workflow.interfaces import IWorkflowPublicationInfo
       
    21 
       
    22 
       
    23 from pyams_content import _
       
    24 
       
    25 
       
    26 @adapter_config(context=(ISiteFolder, IPyAMSUserLayer), provides=ISiteElementNavigation)
       
    27 class SiteFolderNavigationAdapter(ContextRequestAdapter):
       
    28     """Site folder navigation adapter"""
       
    29 
       
    30     @property
       
    31     def visible(self):
       
    32         if not self.context.visible_in_list:
       
    33             return False
       
    34         return IWorkflowPublicationInfo(self.context).is_visible(self.request)
       
    35 
       
    36 
       
    37 @adapter_config(context=(ISiteFolder, IPyAMSUserLayer), provides=IContentSummaryInfo)
       
    38 class SiteFolderSummaryAdapter(ContextRequestAdapter):
       
    39     """Site folder summary adapter"""
       
    40 
       
    41     @property
       
    42     def title(self):
       
    43         i18n = II18n(self.context)
       
    44         return i18n.query_attribute('navigation_title', request=self.request) or \
       
    45             i18n.query_attribute('title', request=self.request)
       
    46 
       
    47     @property
       
    48     def header(self):
       
    49         try:
       
    50             return II18n(self.context).query_attribute('header', request=self.request)
       
    51         except AttributeError:
       
    52             return None
       
    53 
       
    54     button_title = _("Consult folder")