Add read-only boolean form field widget.
Developers should be able to view, but not change, the User's agrees_to_tos
state.
Patch by: Todd Larsen
Review by: to-be-reviewed
--- a/app/soc/views/helper/widgets.py Wed Jan 14 22:02:39 2009 +0000
+++ b/app/soc/views/helper/widgets.py Wed Jan 14 22:30:24 2009 +0000
@@ -44,6 +44,21 @@
return super(ReadOnlyInput, self).render(name, value, attrs)
+class ReadOnlyBool(forms.widgets.Input):
+ """Read only checkbox widget.
+ """
+ input_type = 'checkbox'
+
+ def render(self, name, value, attrs=None):
+ """Render ReadOnlyBool widget as HTML.
+ """
+ # TODO(tlarsen): this really should display "Yes" or "No" (wrapped with
+ # ugettext_lazy(), of course), instead of displaying a greyed-out but
+ # toggleable checkbox (that has no effect on the field, though).
+ attrs['readonly'] = 'readonly'
+ return super(ReadOnlyBool, self).render(name, value, attrs)
+
+
class TinyMCE(forms.widgets.Textarea):
"""TinyMCE widget.