|
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 z3c.form import field |
|
16 |
|
17 from pyams_content.features.search import ISearchFolder |
|
18 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION |
|
19 from pyams_content.shared.view.interfaces import IViewTagsSettings, IViewThemesSettings, IViewCollectionsSettings |
|
20 from pyams_content.shared.view.zmi.theme import ViewTagsEditForm, ViewThemesEditForm, ViewCollectionsEditForm |
|
21 from pyams_form.form import ajax_config |
|
22 from pyams_pagelet.pagelet import pagelet_config |
|
23 from pyams_skin.layer import IPyAMSLayer |
|
24 from pyams_thesaurus.zmi.widget import ThesaurusTermsTreeFieldWidget |
|
25 from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION |
|
26 |
|
27 from pyams_content import _ |
|
28 |
|
29 |
|
30 @pagelet_config(name='tags.html', context=ISearchFolder, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
|
31 @ajax_config(name='tags.json', context=ISearchFolder, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) |
|
32 class SearchFolderTagsEditForm(ViewTagsEditForm): |
|
33 """Search folder tags settings edit form""" |
|
34 |
|
35 legend = _("Search folder tags settings") |
|
36 |
|
37 fields = field.Fields(IViewTagsSettings).select('tags') |
|
38 fields['tags'].widgetFactory = ThesaurusTermsTreeFieldWidget |
|
39 |
|
40 def updateWidgets(self, prefix=None): |
|
41 super(SearchFolderTagsEditForm, self).updateWidgets(prefix) |
|
42 if 'tags' in self.widgets: |
|
43 self.widgets['tags'].label_css_class = 'hidden' |
|
44 |
|
45 |
|
46 @pagelet_config(name='themes.html', context=ISearchFolder, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
|
47 @ajax_config(name='themes.json', context=ISearchFolder, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) |
|
48 class SearchFolderThemesEditForm(ViewThemesEditForm): |
|
49 """Search folder themes settings edit form""" |
|
50 |
|
51 legend = _("Search folder themes settings") |
|
52 |
|
53 fields = field.Fields(IViewThemesSettings).select('themes') |
|
54 fields['themes'].widgetFactory = ThesaurusTermsTreeFieldWidget |
|
55 |
|
56 def updateWidgets(self, prefix=None): |
|
57 super(SearchFolderThemesEditForm, self).updateWidgets(prefix) |
|
58 if 'themes' in self.widgets: |
|
59 self.widgets['themes'].label_css_class = 'hidden' |
|
60 |
|
61 |
|
62 @pagelet_config(name='collections.html', context=ISearchFolder, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
|
63 @ajax_config(name='collections.json', context=ISearchFolder, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) |
|
64 class SearchFolderCollectionsEditForm(ViewCollectionsEditForm): |
|
65 """Search folder collections settings edit form""" |
|
66 |
|
67 legend = _("Search folder collections settings") |
|
68 |
|
69 fields = field.Fields(IViewCollectionsSettings).select('collections') |
|
70 fields['collections'].widgetFactory = ThesaurusTermsTreeFieldWidget |
|
71 |
|
72 def updateWidgets(self, prefix=None): |
|
73 super(SearchFolderCollectionsEditForm, self).updateWidgets(prefix) |
|
74 if 'collections' in self.widgets: |
|
75 self.widgets['collections'].label_css_class = 'hidden' |