src/pyams_content/features/search/__init__.py
changeset 1061 d1db251eeea3
child 1121 852aa448da04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/features/search/__init__.py	Wed Nov 07 17:29:54 2018 +0100
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 2008-2018 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 zope.interface import implementer
+from zope.schema.fieldproperty import FieldProperty
+
+from pyams_content.component.illustration import IIllustrationTarget, ILinkIllustrationTarget
+from pyams_content.features.preview.interfaces import IPreviewTarget
+from pyams_content.features.search.interfaces import ISearchFolder, ISearchFolderRoles
+from pyams_content.interfaces import MANAGE_SITE_PERMISSION, MANAGER_ROLE, GUEST_ROLE
+from pyams_content.shared.view import WfView
+from pyams_form.interfaces.form import IFormContextPermissionChecker
+from pyams_portal.interfaces import IPortalContext, DESIGNER_ROLE
+from pyams_utils.adapter import ContextAdapter, adapter_config
+
+from pyams_content import _
+
+
+@implementer(ISearchFolder, ISearchFolderRoles, IIllustrationTarget, ILinkIllustrationTarget,
+             IPortalContext, IPreviewTarget)
+class SearchFolder(WfView):
+    """Search folder"""
+
+    __roles__ = (MANAGER_ROLE, DESIGNER_ROLE, GUEST_ROLE)
+    roles_interface = ISearchFolderRoles
+
+    content_name = _("Search folder")
+
+    handle_content_url = True
+    handle_header = True
+    handle_description = True
+
+    sequence_name = ''  # use default sequence generator
+    sequence_prefix = ''
+
+    selected_content_types = FieldProperty(ISearchFolder['selected_content_types'])
+    selected_datatypes = FieldProperty(ISearchFolder['selected_datatypes'])
+
+    visible_in_list = FieldProperty(ISearchFolder['visible_in_list'])
+    navigation_title = FieldProperty(ISearchFolder['navigation_title'])
+
+    @staticmethod
+    def is_deletable():
+        return True
+
+
+@adapter_config(context=ISearchFolder, provides=IFormContextPermissionChecker)
+class SearchFolderPermissionChecker(ContextAdapter):
+    """Search folder edit permission checker"""
+
+    edit_permission = MANAGE_SITE_PERMISSION