# HG changeset patch # User Thierry Florac # Date 1546618204 -3600 # Node ID fcc1cf94976c7b93a332d15fdc9ec8bf4c7fd6b6 # Parent 0ec8963e088e51fbb3a46200980e0e572354571e Added dashboard column to display data-type of typed contents diff -r 0ec8963e088e -r fcc1cf94976c src/pyams_content/shared/common/zmi/dashboard.py --- a/src/pyams_content/shared/common/zmi/dashboard.py Fri Jan 04 12:20:34 2019 +0100 +++ b/src/pyams_content/shared/common/zmi/dashboard.py Fri Jan 04 17:10:04 2019 +0100 @@ -9,6 +9,8 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # +from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent + __docformat__ = 'restructuredtext' @@ -97,6 +99,23 @@ return tuple(super(BaseDashboardTable, self).values) +@adapter_config(name='type', context=(Interface, IPyAMSLayer, IDashboardTable), provides=IColumn) +class SharedToolDashboardTypeColumn(I18nColumn, GetAttrColumn): + """Shared tool dashboard type column""" + + _header = _("Type") + weight = 9 + + def getValue(self, obj): + content = IWfTypedSharedContent(obj, None) + if content is not None: + data_type = content.get_data_type() + if data_type is not None: + return II18n(data_type).query_attribute('navigation_label', request=self.request) or \ + II18n(data_type).query_attribute('label', request=self.request) + return '--' + + @adapter_config(name='name', context=(Interface, IPyAMSLayer, IDashboardTable), provides=IColumn) class SharedToolDashboardNameColumn(NameColumn): """Shared tool dashboard name column"""