summaryrefslogtreecommitdiff
path: root/django/forms/widgets.py
diff options
context:
space:
mode:
authorJason Myers <jason@jasonamyers.com>2013-11-02 16:34:05 -0500
committerJason Myers <jason@jasonamyers.com>2013-11-02 23:48:47 -0500
commitc3791463a5a9674f8e0148fbab57eae23c138896 (patch)
tree6606acdb74132a344a49e910dec5d0356389a569 /django/forms/widgets.py
parent2a03a9a9a1c4517be75e72899e545b0bc9dd0688 (diff)
Fixing E302 Errors
Signed-off-by: Jason Myers <jason@jasonamyers.com>
Diffstat (limited to 'django/forms/widgets.py')
-rw-r--r--django/forms/widgets.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 88dc28d664..e6707f9557 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -104,6 +104,7 @@ class Media(object):
getattr(combined, 'add_' + name)(getattr(other, '_' + name, None))
return combined
+
def media_property(cls):
def _media(self):
# Get the media property of the superclass, if it exists
@@ -131,6 +132,7 @@ def media_property(cls):
return base
return property(_media)
+
class MediaDefiningClass(type):
"""
Metaclass for classes that can have media definitions.
@@ -162,6 +164,7 @@ class SubWidget(object):
args.append(self.choices)
return self.parent_widget.render(*args)
+
class Widget(six.with_metaclass(MediaDefiningClass)):
is_hidden = False # Determines whether this corresponds to an <input type="hidden">.
needs_multipart_form = False # Determines does this widget need multipart form
@@ -224,6 +227,7 @@ class Widget(six.with_metaclass(MediaDefiningClass)):
"""
return id_
+
class Input(Widget):
"""
Base class for all <input> widgets (except type='checkbox' and
@@ -279,10 +283,12 @@ class PasswordInput(TextInput):
value = None
return super(PasswordInput, self).render(name, value, attrs)
+
class HiddenInput(Input):
input_type = 'hidden'
is_hidden = True
+
class MultipleHiddenInput(HiddenInput):
"""
A widget that handles <input type="hidden"> for fields that have a list
@@ -313,6 +319,7 @@ class MultipleHiddenInput(HiddenInput):
return data.getlist(name)
return data.get(name, None)
+
class FileInput(Input):
input_type = 'file'
needs_multipart_form = True
@@ -327,6 +334,7 @@ class FileInput(Input):
FILE_INPUT_CONTRADICTION = object()
+
class ClearableFileInput(FileInput):
initial_text = ugettext_lazy('Currently')
input_text = ugettext_lazy('Change')
@@ -379,7 +387,8 @@ class ClearableFileInput(FileInput):
def value_from_datadict(self, data, files, name):
upload = super(ClearableFileInput, self).value_from_datadict(data, files, name)
if not self.is_required and CheckboxInput().value_from_datadict(
- data, files, self.clear_checkbox_name(name)):
+ data, files, self.clear_checkbox_name(name)):
+
if upload:
# If the user contradicts themselves (uploads a new file AND
# checks the "clear" checkbox), we return a unique marker
@@ -389,6 +398,7 @@ class ClearableFileInput(FileInput):
return False
return upload
+
class Textarea(Widget):
def __init__(self, attrs=None):
# The 'rows' and 'cols' attributes are required for HTML correctness.
@@ -515,6 +525,7 @@ class Select(Widget):
output.append(self.render_option(selected_choices, option_value, option_label))
return '\n'.join(output)
+
class NullBooleanSelect(Select):
"""
A Select Widget intended to be used with NullBooleanField.
@@ -849,6 +860,7 @@ class SplitDateTimeWidget(MultiWidget):
return [value.date(), value.time().replace(microsecond=0)]
return [None, None]
+
class SplitHiddenDateTimeWidget(SplitDateTimeWidget):
"""
A Widget that splits datetime input into two <input type="hidden"> inputs.