--- a/src/pyams_default_theme/shared/common/__init__.py Wed Sep 25 10:05:57 2019 +0200
+++ b/src/pyams_default_theme/shared/common/__init__.py Wed Sep 25 10:07:52 2019 +0200
@@ -14,6 +14,7 @@
from pyams_content.interfaces import IBaseContent
from pyams_content.shared.common.interfaces import IWfSharedContent
+from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
from pyams_default_theme.interfaces import IContentDate, IContentTag, IContentTitle
from pyams_i18n.interfaces import II18n
from pyams_skin.interfaces.metas import IHTMLContentMetas
@@ -28,6 +29,36 @@
__docformat__ = 'restructuredtext'
+@adapter_config(name='content_type',
+ context=(Interface, IPyAMSUserLayer, Interface),
+ provides=ITALESExtension)
+class PyAMSContentTypeTALESExtension(ContextRequestViewAdapter):
+ """PyAMS content type TALES extension"""
+
+ def render(self, context=None):
+ if context is None:
+ context = self.context
+ content = IWfSharedContent(context, None)
+ if content is not None:
+ return self.request.localizer.translate(content.content_name)
+
+
+@adapter_config(name='data_type',
+ context=(Interface, IPyAMSUserLayer, Interface),
+ provides=ITALESExtension)
+class PyAMSContentDatatypeTALESExtension(ContextRequestViewAdapter):
+ """PyAMS content data type TALES extension"""
+
+ def render(self, context=None):
+ if context is None:
+ context = self.context
+ content = IWfTypedSharedContent(context, None)
+ if content is not None:
+ data_type = content.get_data_type()
+ if data_type is not None:
+ return II18n(data_type).query_attribute('label', request=self.request)
+
+
@adapter_config(name='title', context=(IWfSharedContent, IPyAMSUserLayer, Interface),
provides=IHTMLContentMetas)
class SharedContentTitleMetasAdapter(ContextRequestViewAdapter):