X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=apps%2Fpatchwork%2Fviews%2Fxmlrpc.py;h=eebc2aae48600179471782fe8ee55e52a845d83a;hb=67181f5c929018d5304732969f0811795c13ea37;hp=bb9ebe15d82a9df37176d6fa42167db7efdb7073;hpb=f23f76b8756a12614097fec500d3ca3e6aa3227b;p=patchwork diff --git a/apps/patchwork/views/xmlrpc.py b/apps/patchwork/views/xmlrpc.py index bb9ebe1..eebc2aa 100644 --- a/apps/patchwork/views/xmlrpc.py +++ b/apps/patchwork/views/xmlrpc.py @@ -26,6 +26,7 @@ from django.http import HttpResponse, HttpResponseRedirect, \ 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 @@ -167,11 +168,19 @@ def project_to_dict(obj): 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"), } @@ -328,7 +337,7 @@ def patch_list(filter={}): patches = Patch.objects.filter(**dfilter) if max_count > 0: - return map(patch_to_dict, patches)[:max_count] + return map(patch_to_dict, patches[:max_count]) else: return map(patch_to_dict, patches) @@ -368,7 +377,7 @@ def patch_get_mbox(patch_id): """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 ""