# HG changeset patch # User Todd Larsen # Date 1231972224 0 # Node ID 36280f13773103f16d406828f38caf72e2dc416e # Parent 9e56019eb2180525b257a5661c865b0668e1cb21 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 diff -r 9e56019eb218 -r 36280f137731 app/soc/views/helper/widgets.py --- 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.