|
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 pyams_content.shared.common import ISharedContent, IWfSharedContent |
|
16 from pyams_default_theme.interfaces import IContentSummaryInfo |
|
17 from pyams_i18n.interfaces import II18n |
|
18 from pyams_skin.layer import IPyAMSUserLayer |
|
19 from pyams_utils.adapter import ContextRequestAdapter, adapter_config |
|
20 |
|
21 from pyams_content import _ |
|
22 |
|
23 |
|
24 @adapter_config(context=(IWfSharedContent, IPyAMSUserLayer), provides=IContentSummaryInfo) |
|
25 class WfSharedContentSummaryInfo(ContextRequestAdapter): |
|
26 """Shared content summary info adapter""" |
|
27 |
|
28 @property |
|
29 def title(self): |
|
30 return II18n(self.context).query_attribute('title', request=self.request) |
|
31 |
|
32 @property |
|
33 def header(self): |
|
34 return II18n(self.context).query_attribute('header', request=self.request) |
|
35 |
|
36 @property |
|
37 def button_title(self): |
|
38 return _("Consult content") |
|
39 |
|
40 |
|
41 @adapter_config(context=(ISharedContent, IPyAMSUserLayer), provides=IContentSummaryInfo) |
|
42 def shared_content_summary_adapter(context, request): |
|
43 """Shared content summary adapter""" |
|
44 version = context.published_version |
|
45 if version is not None: |
|
46 return request.registry.queryMultiAdapter((version, request), IContentSummaryInfo) |