Commit 55ef9290 authored by Dirk Wallenstein's avatar Dirk Wallenstein Committed by Jeremy Kerr
Browse files

Use an explicit initial default patch state



This will make editing states through the admin UI less error-prone, and
will facilitate parsing patches when relying on a default state, as well as
testing.

Use the explicit default state when parsing mails.
Signed-off-by: default avatarDirk Wallenstein <halsmit@t-online.de>
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
parent b76f7dd3
......@@ -34,10 +34,10 @@ except ImportError:
from email.Utils import parsedate_tz, mktime_tz
from patchwork.parser import parse_patch
from patchwork.models import Patch, Project, Person, Comment, State
from patchwork.models import Patch, Project, Person, Comment, State, \
get_default_initial_patch_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 +349,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 get_default_initial_patch_state()
def get_delegate(delegate_email):
""" Return the delegate with the given email or None """
......
......@@ -191,6 +191,9 @@ class PatchMbox(MIMENonMultipart):
self.set_payload(_text.encode(self.patch_charset))
encode_7or8bit(self)
def get_default_initial_patch_state():
return State.objects.get(ordering=0)
class Patch(models.Model):
project = models.ForeignKey(Project)
msgid = models.CharField(max_length=255)
......@@ -198,7 +201,7 @@ class Patch(models.Model):
date = models.DateTimeField(default=datetime.datetime.now)
submitter = models.ForeignKey(Person)
delegate = models.ForeignKey(User, blank = True, null = True)
state = models.ForeignKey(State)
state = models.ForeignKey(State, default=get_default_initial_patch_state)
archived = models.BooleanField(default = False)
headers = models.TextField(blank = True)
content = models.TextField(null = True, blank = True)
......
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