8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
12 |
12 |
13 __docformat__ = 'restructuredtext' |
13 from zope.interface import Attribute, Interface, Invalid, invariant |
14 |
|
15 from zope.interface import Interface |
|
16 from zope.schema import Bool, Choice, Set |
14 from zope.schema import Bool, Choice, Set |
17 |
15 |
18 from pyams_content import _ |
|
19 from pyams_content.interfaces import GUEST_ROLE, IBaseContent, MANAGER_ROLE |
16 from pyams_content.interfaces import GUEST_ROLE, IBaseContent, MANAGER_ROLE |
20 from pyams_content.shared.common.interfaces import SHARED_CONTENT_TYPES_VOCABULARY |
17 from pyams_content.shared.common.interfaces import SHARED_CONTENT_TYPES_VOCABULARY |
21 from pyams_content.shared.common.interfaces.types import ALL_DATA_TYPES_VOCABULARY |
18 from pyams_content.shared.common.interfaces.types import ALL_DATA_TYPES_VOCABULARY |
22 from pyams_content.shared.site.interfaces import IBaseSiteItem, ISiteElement |
19 from pyams_content.shared.site.interfaces import IBaseSiteItem, ISiteElement |
23 from pyams_content.shared.view import IWfView |
20 from pyams_content.shared.view import IWfView |
24 from pyams_content.shared.view.interfaces import RELEVANCE_ORDER, USER_VIEW_ORDER_VOCABULARY |
21 from pyams_content.shared.view.interfaces import RELEVANCE_ORDER, USER_VIEW_ORDER_VOCABULARY |
25 from pyams_i18n.schema import I18nTextLineField |
22 from pyams_i18n.schema import I18nTextLineField |
26 from pyams_portal.interfaces import DESIGNER_ROLE |
23 from pyams_portal.interfaces import DESIGNER_ROLE |
27 from pyams_security.schema import PrincipalsSet |
24 from pyams_security.schema import PrincipalsSet |
28 from pyams_sequence.interfaces import IInternalReference, ISequentialIdTarget |
25 from pyams_sequence.interfaces import IInternalReferencesList, ISequentialIdTarget |
29 from pyams_sequence.schema import InternalReferenceField |
26 from pyams_sequence.schema import InternalReferenceField |
30 |
27 |
31 |
28 |
32 class ISearchManagerInfo(IInternalReference): |
29 __docformat__ = 'restructuredtext' |
|
30 |
|
31 from pyams_content import _ |
|
32 |
|
33 |
|
34 class ISearchManagerInfo(IInternalReferencesList): |
33 """Search manager interface""" |
35 """Search manager interface""" |
34 |
36 |
35 reference = InternalReferenceField(title=_("Main search engine"), |
37 reference = InternalReferenceField(title=_("Main search engine"), |
36 description=_("Search folder handling main site search. You can search a " |
38 description=_("Search folder handling main site search. " |
37 "reference using '+' followed by internal number, of by " |
39 "You can search a reference using '+' " |
|
40 "followed by internal number, of by " |
38 "entering text matching content title."), |
41 "entering text matching content title."), |
39 required=False) |
42 required=False) |
|
43 |
|
44 search_target = Attribute("Search target object") |
40 |
45 |
41 name = I18nTextLineField(title=_("Search engine name"), |
46 name = I18nTextLineField(title=_("Search engine name"), |
42 description=_("Name given to the search engine"), |
47 description=_("Name given to the search engine"), |
43 required=False) |
48 required=False) |
44 |
49 |
45 description = I18nTextLineField(title=_("Description"), |
50 description = I18nTextLineField(title=_("Description"), |
46 description=_("Description given to the search engine"), |
51 description=_("Description given to the search engine"), |
47 required=False) |
52 required=False) |
48 |
53 |
|
54 enable_tags_search = Bool(title=_("Enable search by tag?"), |
|
55 description=_("If 'yes', displayed tags will lead to a search " |
|
56 "engine displaying contents matching given tag"), |
|
57 required=True, |
|
58 default=False) |
|
59 |
|
60 tags_search_target = InternalReferenceField(title=_("Tags search target"), |
|
61 description=_("Site or folder where tags search " |
|
62 "is displayed"), |
|
63 required=False) |
|
64 |
|
65 tags_target = Attribute("Tags search target object reference") |
|
66 |
|
67 @invariant |
|
68 def check_tags_search_target(self): |
|
69 if self.enable_tags_search and not self.tags_search_target: |
|
70 raise Invalid(_("You must specify search target when activating search by tags!")) |
|
71 |
|
72 enable_collections_search = Bool(title=_("Enable search by collection?"), |
|
73 description=_("If 'yes', displayed collections will lead to " |
|
74 "a search engine displaying contents matching " |
|
75 "given collection"), |
|
76 required=True, |
|
77 default=False) |
|
78 |
|
79 collections_search_target = InternalReferenceField(title=_("Collections search target"), |
|
80 description=_("Site or folder where " |
|
81 "collections search is " |
|
82 "displayed"), |
|
83 required=False) |
|
84 |
|
85 collections_target = Attribute("Collections search target object reference") |
|
86 |
|
87 @invariant |
|
88 def check_collections_search_target(self): |
|
89 if self.enable_collections_search and not self.collections_search_target: |
|
90 raise Invalid(_("You must specify search target when activating search by " |
|
91 "collections!")) |
|
92 |
49 |
93 |
50 class ISearchFolderRoles(Interface): |
94 class ISearchFolderRoles(Interface): |
51 """Search folder roles""" |
95 """Search folder roles""" |
52 |
96 |
53 managers = PrincipalsSet(title=_("Managers"), |
97 managers = PrincipalsSet(title=_("Managers"), |
54 description=_("Managers can handle main operations in tool's workflow, like publish " |
98 description=_("Managers can handle main operations in tool's " |
55 "or retire contents"), |
99 "workflow, like publish or retire contents"), |
56 role_id=MANAGER_ROLE, |
100 role_id=MANAGER_ROLE, |
57 required=False) |
101 required=False) |
58 |
102 |
59 designers = PrincipalsSet(title=_("Designers"), |
103 designers = PrincipalsSet(title=_("Designers"), |
60 description=_("Designers are users which are allowed to manage presentation templates"), |
104 description=_("Designers are users which are allowed to manage " |
|
105 "presentation templates"), |
61 role_id=DESIGNER_ROLE, |
106 role_id=DESIGNER_ROLE, |
62 required=False) |
107 required=False) |
63 |
108 |
64 guests = PrincipalsSet(title=_("Guests"), |
109 guests = PrincipalsSet(title=_("Guests"), |
65 description=_("Guests are users which are allowed to view contents with restricted access"), |
110 description=_("Guests are users which are allowed to view contents " |
|
111 "with restricted access"), |
66 role_id=GUEST_ROLE, |
112 role_id=GUEST_ROLE, |
67 required=False) |
113 required=False) |
68 |
114 |
69 |
115 |
70 class ISearchFolder(IBaseContent, IBaseSiteItem, ISiteElement, IWfView, ISequentialIdTarget): |
116 class ISearchFolder(IBaseContent, IBaseSiteItem, ISiteElement, IWfView, ISequentialIdTarget): |
71 """Search folder interface""" |
117 """Search folder interface""" |
72 |
118 |
73 order_by = Choice(title=_("Order by"), |
119 order_by = Choice(title=_("Order by"), |
74 description=_("Property to use to sort results; publication date can be different from first " |
120 description=_("Property to use to sort results; publication date can be " |
75 "publication date for contents which have been retired and re-published with a " |
121 "different from first publication date for contents which " |
76 "different publication date"), |
122 "have been retired and re-published with a different " |
|
123 "publication date"), |
77 vocabulary=USER_VIEW_ORDER_VOCABULARY, |
124 vocabulary=USER_VIEW_ORDER_VOCABULARY, |
78 required=False, |
125 required=False, |
79 default=RELEVANCE_ORDER) |
126 default=RELEVANCE_ORDER) |
80 |
127 |
81 visible_in_list = Bool(title=_("Visible in folders list"), |
128 visible_in_list = Bool(title=_("Visible in folders list"), |
82 description=_("If 'no', folder will not be displayed into folders list"), |
129 description=_("If 'no', folder will not be displayed into folders " |
|
130 "list"), |
83 required=True, |
131 required=True, |
84 default=True) |
132 default=True) |
85 |
133 |
86 navigation_title = I18nTextLineField(title=_("Navigation title"), |
134 navigation_title = I18nTextLineField(title=_("Navigation title"), |
87 description=_("Folder's title displayed in navigation pages; " |
135 description=_("Folder's title displayed in navigation " |
88 "original title will be used if none is specified"), |
136 "pages; original title will be used if " |
|
137 "none is specified"), |
89 required=False) |
138 required=False) |
90 |
139 |
91 selected_content_types = Set(title=_("Selected content types"), |
140 selected_content_types = Set(title=_("Selected content types"), |
92 description=_("Searched content types; leave empty for all"), |
141 description=_("Searched content types; leave empty for all"), |
93 value_type=Choice(vocabulary=SHARED_CONTENT_TYPES_VOCABULARY), |
142 value_type=Choice(vocabulary=SHARED_CONTENT_TYPES_VOCABULARY), |