From patchwork Thu Apr 26 15:03:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Wallenstein X-Patchwork-Id: 155290 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 E5382B6FDE for ; Fri, 27 Apr 2012 01:03:37 +1000 (EST) Received: from mailout01.t-online.de (mailout01.t-online.de [194.25.134.80]) by ozlabs.org (Postfix) with ESMTP id 14929B6EF1 for ; Fri, 27 Apr 2012 01:03:33 +1000 (EST) Received: from fwd01.aul.t-online.de (fwd01.aul.t-online.de ) by mailout01.t-online.de with smtp id 1SNQEC-0001Em-8p; Thu, 26 Apr 2012 17:03:28 +0200 Received: from localhost (bjUX9+ZGrhnjNhFyKu2EMFBju8e7ocCXLL7+JNlofZlnPxcEhqBzWDUZZ302tlDgOz@[109.91.88.236]) by fwd01.t-online.de with esmtp id 1SNQE9-0d9Ghk0; Thu, 26 Apr 2012 17:03:25 +0200 Date: Thu, 26 Apr 2012 17:03:21 +0200 From: Dirk Wallenstein To: Jeremy Kerr Subject: [PATCH] parser: Use initial patch state encoded in the model Message-ID: <20120426150321.GA15111@bottich> References: <1296046625-25263-1-git-send-email-halsmit@t-online.de> <1296054749-13453-1-git-send-email-halsmit@t-online.de> <20120424063329.D101E20024F@gemini.denx.de> <20120424111515.GA17273@bottich> <20120426124905.722C8200246@gemini.denx.de> <20120426125351.GA19981@bottich> <4F995890.1000002@ozlabs.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4F995890.1000002@ozlabs.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-ID: bjUX9+ZGrhnjNhFyKu2EMFBju8e7ocCXLL7+JNlofZlnPxcEhqBzWDUZZ302tlDgOz X-TOI-MSGID: 49f88338-a115-4ee0-8e52-5160cb83d2cc Cc: patchwork@lists.ozlabs.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 Signed-off-by: Dirk Wallenstein --- (untested, need a bit to get back into it. I cannot assign None to select the default state, can I?) apps/patchwork/bin/parsemail.py | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/patchwork/bin/parsemail.py b/apps/patchwork/bin/parsemail.py index 52c85fe..2512055 100755 --- a/apps/patchwork/bin/parsemail.py +++ b/apps/patchwork/bin/parsemail.py @@ -37,7 +37,6 @@ from patchwork.parser import parse_patch from patchwork.models import Patch, Project, Person, Comment, State from django.contrib.auth.models import User -default_patch_state = 'New' list_id_headers = ['List-ID', 'X-Mailing-List', 'X-list'] whitespace_re = re.compile('\s+') @@ -349,7 +348,7 @@ def get_state(state_name): return State.objects.get(name__iexact=state_name) except State.DoesNotExist: pass - return State.objects.get(name=default_patch_state) + return None def get_delegate(delegate_email): """ Return the delegate with the given email or None """ @@ -395,9 +394,13 @@ def parse_mail(mail): patch.submitter = author patch.msgid = msgid patch.project = project - patch.state = get_state(mail.get('X-Patchwork-State', '').strip()) patch.delegate = get_delegate( mail.get('X-Patchwork-Delegate', '').strip()) + initial_patch_state = get_state( + mail.get('X-Patchwork-State', '').strip()) + if not initial_patch_state is None: + patch.state = initial_patch_state + try: patch.save() except Exception, ex: