diff options
author | Guilherme Salgado <guilherme.salgado@linaro.org> | 2011-04-13 06:11:07 +0000 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2011-04-14 15:07:43 +0800 |
commit | c3291f5d18445cd91b540342d31d76254b32376c (patch) | |
tree | 814654971409d9a133ab5283da1bcbd679d2b743 | |
parent | 046abd4966f0afed33e29ba1474147e37fd35d32 (diff) | |
download | patchwork-c3291f5d18445cd91b540342d31d76254b32376c.tar patchwork-c3291f5d18445cd91b540342d31d76254b32376c.tar.gz |
forms: Fix MultipleBooleanField.to_python when the field value is missing
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>
-rw-r--r-- | apps/patchwork/forms.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/apps/patchwork/forms.py b/apps/patchwork/forms.py index 3d3abb3..1ff2bd0 100644 --- a/apps/patchwork/forms.py +++ b/apps/patchwork/forms.py @@ -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': |