from django.core import urlresolvers
from django.contrib.auth import authenticate
from patchwork.models import Patch, Project, Person, State
+from patchwork.views import patch_to_mbox
from django.views.decorators.csrf import csrf_exempt
import sys
def person_to_dict(obj):
"""Return a trimmed down dictionary representation of a Person
object which is OK to send to the client."""
+
+ # Make sure we don't return None even if the user submitted a patch
+ # with no real name. XMLRPC can't marshall None.
+ if obj.name is not None:
+ name = obj.name
+ else:
+ name = obj.email
+
return \
{
'id' : obj.id,
'email' : obj.email,
- 'name' : obj.name,
+ 'name' : name,
'user' : unicode(obj.user).encode("utf-8"),
}
"""Return mbox string for the given patch ID."""
try:
patch = Patch.objects.filter(id = patch_id)[0]
- return patch.mbox().as_string()
+ return patch_to_mbox(patch).as_string()
except:
return ""