From 531332a5bf2c2edab9f2e4e68bde2e802435cfb0 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 18 Aug 2011 10:53:19 -0400 Subject: [PATCH] Removed debug statements, added comments --- apps/common/widgets.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/common/widgets.py b/apps/common/widgets.py index dcbdd69149..5e39ba4742 100644 --- a/apps/common/widgets.py +++ b/apps/common/widgets.py @@ -10,6 +10,10 @@ from django.utils.encoding import force_unicode class PlainWidget(forms.widgets.Widget): + """ + Class to define a form widget that effectively nulls the htmls of a + widget and reduces the output to only it's value + """ def render(self, name, value, attrs=None): return mark_safe(u'%s' % value) @@ -70,6 +74,11 @@ def two_state_template(state, famfam_ok_icon=u'tick', famfam_fail_icon=u'cross') class TextAreaDiv(forms.widgets.Widget): + """ + Class to define a form widget that simulates the behavior of a + Textarea widget but using a div tag instead + """ + def __init__(self, attrs=None): # The 'rows' and 'cols' attributes are required for HTML correctness. default_attrs = {'class': 'text_area_div'} @@ -89,6 +98,10 @@ class TextAreaDiv(forms.widgets.Widget): # From: http://www.peterbe.com/plog/emailinput-html5-django class EmailInput(forms.widgets.Input): + """ + Class for a login form widget that accepts only well formated + email address + """ input_type = 'email' def render(self, name, value, attrs=None): @@ -101,6 +114,11 @@ class EmailInput(forms.widgets.Input): class ScrollableCheckboxSelectMultiple(forms.widgets.CheckboxSelectMultiple): + """ + Class for a form widget composed of a selection of checkboxes wrapped + in a div tag with automatic overflow to add scrollbars when the list + exceds the height of the div + """ def render(self, name, value, attrs=None, choices=()): if value is None: value = [] has_id = attrs and 'id' in attrs @@ -123,8 +141,5 @@ class ScrollableCheckboxSelectMultiple(forms.widgets.CheckboxSelectMultiple): option_label = conditional_escape(force_unicode(option_label)) output.append(u'
  • %s %s
  • ' % (label_for, rendered_cb, option_label)) output.append(u'') - #return mark_safe(u'\n'.join(output)) - result = u'\n'.join(output) - #result = super(ScrollableCheckboxSelectMultiple, self).render(name, value, attrs=None, choices=()) - return mark_safe(u'
    %s
    ' % result) + return mark_safe(u'
    %s
    ' % u'\n'.join(output))