Author: eallen
Date: 2008-08-14 14:44:43 -0400 (Thu, 14 Aug 2008)
New Revision: 2307
Modified:
mgmt/trunk/cumin/python/cumin/widgets.py
Log:
Making FilteredCheckboxIdColumn more extensible by using a callback instead of field name
and values
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2008-08-14 18:36:13 UTC (rev 2306)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2008-08-14 18:44:43 UTC (rev 2307)
@@ -577,16 +577,16 @@
return self.column.ids.path
class FilteredCheckboxIdColumn(CheckboxIdColumn):
- def __init__(self, app, name, form, col_name, skip_list):
+ def __init__(self, app, name, form, callback=None):
super(FilteredCheckboxIdColumn, self).__init__(app, name, form)
- # list of names to skip putting a checkbox by
- self.__skip_list = skip_list
- self.__col_name = col_name
+ # call back that returns True if the checkbox is to be disabled
+ self.__callback = callback
def do_render(self, session, data):
+ disabled = self.__callback and self.__callback(session, data) or False
return super(FilteredCheckboxIdColumn, self).do_render(session, data,
- disabled=data[self.__col_name] in self.__skip_list)
+ disabled=disabled)
class NameField(StringField):
def __init__(self, app, name, form):
Show replies by date