diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2010-09-02 18:47:38 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2010-09-02 19:50:34 +0800 |
commit | 73960c4331e70da50b65ac753558578ada03d9ce (patch) | |
tree | 7092308d51b50ec6168ba80a195ff670d644c848 | |
parent | f7535e706ecbf4c28f21e52978db12b3ec9e1f54 (diff) | |
download | patchwork-73960c4331e70da50b65ac753558578ada03d9ce.tar patchwork-73960c4331e70da50b65ac753558578ada03d9ce.tar.gz |
forms.MultiplePatchForm: remove no-change fields on clean()
We need to remove no-change fields, as newer versions of django are
checking for proper types on validation.
Fixes MultipleUpdateTest.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | apps/patchwork/forms.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/apps/patchwork/forms.py b/apps/patchwork/forms.py index f78a105..2c137e3 100644 --- a/apps/patchwork/forms.py +++ b/apps/patchwork/forms.py @@ -186,6 +186,21 @@ class MultiplePatchForm(PatchForm): self.fields['delegate'] = OptionalDelegateField(project = project, required = False) + def _clean_fields(self): + super(MultiplePatchForm, self)._clean_fields() + # remove optional fields + opts = self.instance._meta + for f in opts.fields: + if not f.name in self.cleaned_data: + continue + + field = self.fields.get(f.name, None) + if field is None: + continue + + if field.is_no_change(self.cleaned_data[f.name]): + del self.cleaned_data[f.name] + def save(self, instance, commit = True): opts = instance.__class__._meta if self.errors: |