src/pyams_content/features/search/__init__.py
changeset 1061 d1db251eeea3
child 1121 852aa448da04
equal deleted inserted replaced
1060:29b1aaf9e080 1061:d1db251eeea3
       
     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 zope.interface import implementer
       
    16 from zope.schema.fieldproperty import FieldProperty
       
    17 
       
    18 from pyams_content.component.illustration import IIllustrationTarget, ILinkIllustrationTarget
       
    19 from pyams_content.features.preview.interfaces import IPreviewTarget
       
    20 from pyams_content.features.search.interfaces import ISearchFolder, ISearchFolderRoles
       
    21 from pyams_content.interfaces import MANAGE_SITE_PERMISSION, MANAGER_ROLE, GUEST_ROLE
       
    22 from pyams_content.shared.view import WfView
       
    23 from pyams_form.interfaces.form import IFormContextPermissionChecker
       
    24 from pyams_portal.interfaces import IPortalContext, DESIGNER_ROLE
       
    25 from pyams_utils.adapter import ContextAdapter, adapter_config
       
    26 
       
    27 from pyams_content import _
       
    28 
       
    29 
       
    30 @implementer(ISearchFolder, ISearchFolderRoles, IIllustrationTarget, ILinkIllustrationTarget,
       
    31              IPortalContext, IPreviewTarget)
       
    32 class SearchFolder(WfView):
       
    33     """Search folder"""
       
    34 
       
    35     __roles__ = (MANAGER_ROLE, DESIGNER_ROLE, GUEST_ROLE)
       
    36     roles_interface = ISearchFolderRoles
       
    37 
       
    38     content_name = _("Search folder")
       
    39 
       
    40     handle_content_url = True
       
    41     handle_header = True
       
    42     handle_description = True
       
    43 
       
    44     sequence_name = ''  # use default sequence generator
       
    45     sequence_prefix = ''
       
    46 
       
    47     selected_content_types = FieldProperty(ISearchFolder['selected_content_types'])
       
    48     selected_datatypes = FieldProperty(ISearchFolder['selected_datatypes'])
       
    49 
       
    50     visible_in_list = FieldProperty(ISearchFolder['visible_in_list'])
       
    51     navigation_title = FieldProperty(ISearchFolder['navigation_title'])
       
    52 
       
    53     @staticmethod
       
    54     def is_deletable():
       
    55         return True
       
    56 
       
    57 
       
    58 @adapter_config(context=ISearchFolder, provides=IFormContextPermissionChecker)
       
    59 class SearchFolderPermissionChecker(ContextAdapter):
       
    60     """Search folder edit permission checker"""
       
    61 
       
    62     edit_permission = MANAGE_SITE_PERMISSION