]> git.ozlabs.org Git - patchwork/commitdiff
forms: Fix MultipleBooleanField.to_python when the field value is missing
authorGuilherme Salgado <guilherme.salgado@linaro.org>
Wed, 13 Apr 2011 06:11:07 +0000 (06:11 +0000)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 14 Apr 2011 07:07:43 +0000 (15:07 +0800)
If you write a test for, say, the bundle form of a patch list, you'd
still have to specify the 'no change' value to other form (e.g. the
multiple update one) fields using MultipleBooleanField or else it'd
raise a ValueError when field.clean() is called as part of
form._get_errors().

Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/forms.py

index 3d3abb32edf6e0cda6c8a697c7d315443cce4fc0..1ff2bd0088c765711a26c176f652337409bc4d56 100644 (file)
@@ -185,8 +185,8 @@ class MultipleBooleanField(forms.ChoiceField):
         return False
 
     def to_python(self, value):
-        if self.is_no_change(value):
-            return value
+        if value is None or self.is_no_change(value):
+            return self.no_change_choice[0]
         elif value == 'True':
             return True
         elif value == 'False':