From patchwork Thu Apr 26 15:03:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: parser: Use initial patch state encoded in the model Date: Thu, 26 Apr 2012 05:03:21 -0000 From: Dirk Wallenstein X-Patchwork-Id: 155290 Message-Id: <20120426150321.GA15111@bottich> To: Jeremy Kerr Cc: patchwork@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: