app/soc/views/helper/widgets.py
changeset 812 36280f137731
parent 499 d22e4fe8e64b
child 841 9dac40accd06
--- 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.