Commit 73960c43 authored by Jeremy Kerr's avatar Jeremy Kerr
Browse files

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: default avatarJeremy Kerr <jk@ozlabs.org>
parent f7535e70
...@@ -186,6 +186,21 @@ class MultiplePatchForm(PatchForm): ...@@ -186,6 +186,21 @@ class MultiplePatchForm(PatchForm):
self.fields['delegate'] = OptionalDelegateField(project = project, self.fields['delegate'] = OptionalDelegateField(project = project,
required = False) 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): def save(self, instance, commit = True):
opts = instance.__class__._meta opts = instance.__class__._meta
if self.errors: if self.errors:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment