equal
deleted
inserted
replaced
15 |
15 |
16 # import standard library |
16 # import standard library |
17 |
17 |
18 # import interfaces |
18 # import interfaces |
19 from pyams_content.component.theme.interfaces import IThemesInfo |
19 from pyams_content.component.theme.interfaces import IThemesInfo |
20 from pyams_content.shared.view.interfaces import IViewThemesSettings, IWfView, VIEW_THEMES_SETTINGS_KEY |
20 from pyams_content.shared.view.interfaces import IWfView, IViewSettings, IViewThemesSettings, VIEW_THEMES_SETTINGS_KEY |
21 from zope.annotation.interfaces import IAnnotations |
21 from zope.annotation.interfaces import IAnnotations |
22 |
22 |
23 # import packages |
23 # import packages |
24 from persistent import Persistent |
24 from persistent import Persistent |
25 from pyams_utils.adapter import adapter_config |
25 from pyams_utils.adapter import adapter_config |
36 """View themes settings""" |
36 """View themes settings""" |
37 |
37 |
38 select_context_themes = FieldProperty(IViewThemesSettings['select_context_themes']) |
38 select_context_themes = FieldProperty(IViewThemesSettings['select_context_themes']) |
39 themes = FieldProperty(IViewThemesSettings['themes']) |
39 themes = FieldProperty(IViewThemesSettings['themes']) |
40 |
40 |
|
41 @property |
|
42 def is_using_context(self): |
|
43 return self.select_context_themes |
|
44 |
41 def get_themes(self, context): |
45 def get_themes(self, context): |
42 themes = set() |
46 themes = set() |
43 if self.select_context_themes: |
47 if self.select_context_themes: |
44 themes_info = IThemesInfo(context, None) |
48 themes_info = IThemesInfo(context, None) |
45 if themes_info is not None: |
49 if themes_info is not None: |
51 def get_themes_index(self, context): |
55 def get_themes_index(self, context): |
52 return [theme.label for theme in self.get_themes(context)] |
56 return [theme.label for theme in self.get_themes(context)] |
53 |
57 |
54 |
58 |
55 @adapter_config(context=IWfView, provides=IViewThemesSettings) |
59 @adapter_config(context=IWfView, provides=IViewThemesSettings) |
|
60 @adapter_config(name='themes', context=IWfView, provides=IViewSettings) |
56 def ViewThemesSettingsFactory(view): |
61 def ViewThemesSettingsFactory(view): |
57 """View themes settings factory""" |
62 """View themes settings factory""" |
58 annotations = IAnnotations(view) |
63 annotations = IAnnotations(view) |
59 settings = annotations.get(VIEW_THEMES_SETTINGS_KEY) |
64 settings = annotations.get(VIEW_THEMES_SETTINGS_KEY) |
60 if settings is None: |
65 if settings is None: |