src/pyams_content/features/search/zmi/theme.py
changeset 1297 393e4f1812e1
parent 1061 d1db251eeea3
equal deleted inserted replaced
1296:38e2977b726b 1297:393e4f1812e1
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 from z3c.form import field
    15 from z3c.form import field
    16 
    16 
       
    17 from pyams_content import _
       
    18 from pyams_content.component.theme import ICollectionsManager, ICollectionsManagerTarget, IThemesManager, \
       
    19     IThemesManagerTarget
    17 from pyams_content.features.search import ISearchFolder
    20 from pyams_content.features.search import ISearchFolder
    18 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
    21 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
    19 from pyams_content.shared.view.interfaces import IViewTagsSettings, IViewThemesSettings, IViewCollectionsSettings
    22 from pyams_content.shared.view.interfaces import IViewCollectionsSettings, IViewTagsSettings, IViewThemesSettings
    20 from pyams_content.shared.view.zmi.theme import ViewTagsEditForm, ViewThemesEditForm, ViewCollectionsEditForm
    23 from pyams_content.shared.view.zmi.theme import ViewCollectionsEditForm, ViewTagsEditForm, ViewThemesEditForm
    21 from pyams_form.form import ajax_config
    24 from pyams_form.form import ajax_config
    22 from pyams_pagelet.pagelet import pagelet_config
    25 from pyams_pagelet.pagelet import pagelet_config
    23 from pyams_skin.layer import IPyAMSLayer
    26 from pyams_skin.layer import IPyAMSLayer
    24 from pyams_thesaurus.zmi.widget import ThesaurusTermsTreeFieldWidget
    27 from pyams_thesaurus.zmi.widget import ThesaurusTermsTreeFieldWidget
    25 from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
    28 from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
    26 
    29 from pyams_utils.traversing import get_parent
    27 from pyams_content import _
       
    28 
    30 
    29 
    31 
    30 @pagelet_config(name='tags.html', context=ISearchFolder, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
    32 @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)
    33 @ajax_config(name='tags.json', context=ISearchFolder, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION)
    32 class SearchFolderTagsEditForm(ViewTagsEditForm):
    34 class SearchFolderTagsEditForm(ViewTagsEditForm):
    52 
    54 
    53     fields = field.Fields(IViewThemesSettings).select('themes')
    55     fields = field.Fields(IViewThemesSettings).select('themes')
    54     fields['themes'].widgetFactory = ThesaurusTermsTreeFieldWidget
    56     fields['themes'].widgetFactory = ThesaurusTermsTreeFieldWidget
    55 
    57 
    56     def updateWidgets(self, prefix=None):
    58     def updateWidgets(self, prefix=None):
    57         super(SearchFolderThemesEditForm, self).updateWidgets(prefix)
    59         super(ViewThemesEditForm, self).updateWidgets(prefix)
    58         if 'themes' in self.widgets:
    60         if 'themes' in self.widgets:
    59             self.widgets['themes'].label_css_class = 'hidden'
    61             target = get_parent(self.context, IThemesManagerTarget)
       
    62             manager = IThemesManager(target)
       
    63             widget = self.widgets['themes']
       
    64             widget.label_css_class = 'hidden'
       
    65             widget.input_css_class = 'col-md-12'
       
    66             widget.thesaurus_name = manager.thesaurus_name
       
    67             widget.extract_name = manager.extract_name
    60 
    68 
    61 
    69 
    62 @pagelet_config(name='collections.html', context=ISearchFolder, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
    70 @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)
    71 @ajax_config(name='collections.json', context=ISearchFolder, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION)
    64 class SearchFolderCollectionsEditForm(ViewCollectionsEditForm):
    72 class SearchFolderCollectionsEditForm(ViewCollectionsEditForm):
    68 
    76 
    69     fields = field.Fields(IViewCollectionsSettings).select('collections')
    77     fields = field.Fields(IViewCollectionsSettings).select('collections')
    70     fields['collections'].widgetFactory = ThesaurusTermsTreeFieldWidget
    78     fields['collections'].widgetFactory = ThesaurusTermsTreeFieldWidget
    71 
    79 
    72     def updateWidgets(self, prefix=None):
    80     def updateWidgets(self, prefix=None):
    73         super(SearchFolderCollectionsEditForm, self).updateWidgets(prefix)
    81         super(ViewCollectionsEditForm, self).updateWidgets(prefix)
    74         if 'collections' in self.widgets:
    82         if 'collections' in self.widgets:
    75             self.widgets['collections'].label_css_class = 'hidden'
    83             target = get_parent(self.context, ICollectionsManagerTarget)
       
    84             manager = ICollectionsManager(target)
       
    85             widget = self.widgets['collections']
       
    86             widget.label_css_class = 'hidden'
       
    87             widget.input_css_class = 'col-md-12'
       
    88             widget.thesaurus_name = manager.thesaurus_name
       
    89             widget.extract_name = manager.extract_name