From patchwork Wed Apr 13 16:11:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 91062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id AD559B70E4 for ; Thu, 14 Apr 2011 02:11:17 +1000 (EST) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by ozlabs.org (Postfix) with ESMTP id 8E065B6F94 for ; Thu, 14 Apr 2011 02:11:14 +1000 (EST) Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QA2et-0002Gg-8e; Wed, 13 Apr 2011 16:11:11 +0000 Received: from [187.126.166.24] (helo=feioso) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QA2es-00062t-UC; Wed, 13 Apr 2011 16:11:11 +0000 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by feioso (Postfix) with ESMTP id 7ED3F41879; Wed, 13 Apr 2011 13:11:07 -0300 (BRT) Subject: [PATCH] Make MultipleBooleanField.to_python work when the field value is missing To: patchwork@lists.ozlabs.org From: Guilherme Salgado Date: Wed, 13 Apr 2011 13:11:07 -0300 Message-ID: <20110413161107.17837.3529.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 Cc: patches@linaro.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org 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 --- 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 2c57c08..e069fe9 100644 --- a/apps/patchwork/forms.py +++ b/apps/patchwork/forms.py @@ -187,8 +187,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':