equal
deleted
inserted
replaced
14 |
14 |
15 |
15 |
16 # import standard library |
16 # import standard library |
17 |
17 |
18 # import interfaces |
18 # import interfaces |
|
19 from pyams_i18n.interfaces import II18n |
19 from pyams_skin.interfaces.container import ITable, ITableElementEditor, ITableWithActions, ITableElementName |
20 from pyams_skin.interfaces.container import ITable, ITableElementEditor, ITableWithActions, ITableElementName |
20 from pyams_skin.layer import IPyAMSLayer |
21 from pyams_skin.layer import IPyAMSLayer |
21 from pyams_utils.interfaces import MANAGE_PERMISSION |
22 from pyams_utils.interfaces import MANAGE_PERMISSION |
22 from pyams_viewlet.interfaces import IViewletManager |
23 from pyams_viewlet.interfaces import IViewletManager |
23 from z3c.table.interfaces import IColumn, IValues |
24 from z3c.table.interfaces import IColumn, IValues |
152 @property |
153 @property |
153 def header(self): |
154 def header(self): |
154 if not self._header: |
155 if not self._header: |
155 return '' |
156 return '' |
156 return self.request.localizer.translate(self._header) |
157 return self.request.localizer.translate(self._header) |
|
158 |
|
159 |
|
160 class I18nValueColumn(GetAttrColumn): |
|
161 """Column with I18n value""" |
|
162 |
|
163 def getValue(self, obj): |
|
164 if obj is not None and self.attrName is not None: |
|
165 return II18n(obj).query_attribute(self.attrName, request=self.request) |
|
166 return self.defaultValue |
157 |
167 |
158 |
168 |
159 @adapter_config(name='name', context=(Interface, IPyAMSLayer, BaseTable), provides=IColumn) |
169 @adapter_config(name='name', context=(Interface, IPyAMSLayer, BaseTable), provides=IColumn) |
160 class NameColumn(I18nColumn, GetAttrColumn): |
170 class NameColumn(I18nColumn, GetAttrColumn): |
161 """Container name column""" |
171 """Container name column""" |