[Erp5-report] r18675 - /experimental/Experimental/patches/Formulator_RadioField_show_title.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Sat Jan 12 15:34:06 CET 2008
Author: bartek
Date: Sat Jan 12 15:34:06 2008
New Revision: 18675
URL: http://svn.erp5.org?rev=18675&view=rev
Log:
render disabled RadioField as translated title of selected item
Added:
experimental/Experimental/patches/Formulator_RadioField_show_title.py
Added: experimental/Experimental/patches/Formulator_RadioField_show_title.py
URL: http://svn.erp5.org/experimental/Experimental/patches/Formulator_RadioField_show_title.py?rev=18675&view=auto
==============================================================================
--- experimental/Experimental/patches/Formulator_RadioField_show_title.py (added)
+++ experimental/Experimental/patches/Formulator_RadioField_show_title.py Sat Jan 12 15:34:06 2008
@@ -1,0 +1,44 @@
+##############################################################################
+#
+# Copyright (c) 2007 ERP5 Polska. All Rights Reserved.
+# Bartek Gorny <bartek at erp5.pl>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+##############################################################################
+
+"""
+ This patch renders a disabled RadioField as a translated title
+ of the selected item.
+
+ RATIONALE: currently disabled RadioField displays its value, which may
+ be meaningless to a user who normally sees its title. Would be
+ better to display a translated title of selected item.
+"""
+
+from Products.Formulator.Widget import RadioWidget
+
+def RadioWidget_render_view(self, field, value):
+ def translate(loc, msg):
+ return loc.translate('ui', msg).encode('utf8')
+ loc = getattr(field, 'Localizer', None)
+ if loc is None:
+ translate = lambda loc, msg:msg
+ items = field.get_value('items')
+ for item in items:
+ if item[1] == value:
+ return translate(loc, item[0])
+ return ''
+
+RadioWidget.render_view = RadioWidget_render_view
More information about the Erp5-report
mailing list