]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
forms: 'False' != False
authorStephen Finucane <stephen@that.guru>
Fri, 23 Dec 2016 19:40:59 +0000 (19:40 +0000)
committerStephen Finucane <stephen@that.guru>
Fri, 23 Dec 2016 20:24:22 +0000 (20:24 +0000)
Forms cast boolean values to strings, and attempting to coerce using the
'bool' function does not correctly return them to true boolean values.
Correct this by doing a string comparison instead.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 0abde97aa ("forms: Use TypedChoiceField")
patchwork/forms.py

index 56f1d8655486c40151da80a8ef4902bb7b34d437..f42a224fe75eff3d35c3ddef7de6c593a8458afc 100644 (file)
@@ -178,9 +178,10 @@ class MultiplePatchForm(forms.Form):
     action = 'update'
     state = OptionalModelChoiceField(queryset=State.objects.all())
     archived = OptionalBooleanField(
-        choices=[('*', 'no change'), (True, 'Archived'),
-                 (False, 'Unarchived')],
-        coerce=bool, empty_value='*')
+        choices=[('*', 'no change'), ('True', 'Archived'),
+                 ('False', 'Unarchived')],
+        coerce=lambda x: x == 'True',
+        empty_value='*')
 
     def __init__(self, project, *args, **kwargs):
         super(MultiplePatchForm, self).__init__(*args, **kwargs)