src/pyams_skin/table.py
changeset 206 7ac7101a76c6
parent 198 64511592fb27
child 237 c6c8af288ad3
--- a/src/pyams_skin/table.py	Wed Sep 13 15:54:54 2017 +0200
+++ b/src/pyams_skin/table.py	Tue Sep 19 11:15:38 2017 +0200
@@ -16,6 +16,7 @@
 # import standard library
 
 # import interfaces
+from pyams_i18n.interfaces import II18n
 from pyams_skin.interfaces.container import ITable, ITableElementEditor, ITableWithActions, ITableElementName
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import MANAGE_PERMISSION
@@ -156,6 +157,15 @@
         return self.request.localizer.translate(self._header)
 
 
+class I18nValueColumn(GetAttrColumn):
+    """Column with I18n value"""
+
+    def getValue(self, obj):
+        if obj is not None and self.attrName is not None:
+            return II18n(obj).query_attribute(self.attrName, request=self.request)
+        return self.defaultValue
+
+
 @adapter_config(name='name', context=(Interface, IPyAMSLayer, BaseTable), provides=IColumn)
 class NameColumn(I18nColumn, GetAttrColumn):
     """Container name column"""