]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/views/xmlrpc.py
tox: Add tox.ini file
[patchwork] / apps / patchwork / views / xmlrpc.py
index 283eb34be865fd129c5b1ddcd09328f3fa98e225..84ed4089b346812f241789e35af4e69624302080 100644 (file)
@@ -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
@@ -99,7 +100,7 @@ class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher):
 
     def _marshaled_dispatch(self, request):
         try:
-            params, method = xmlrpclib.loads(request.raw_post_data)
+            params, method = xmlrpclib.loads(request.body)
 
             response = self._dispatch(request, method, params)
             # wrap response in a singleton tuple
@@ -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"),
         }
 
@@ -189,6 +198,7 @@ def patch_to_dict(obj):
          'project_id'   : obj.project_id,
          'state'        : unicode(obj.state).encode("utf-8"),
          'state_id'     : obj.state_id,
+         'archived'     : obj.archived,
          'submitter'    : unicode(obj.submitter).encode("utf-8"),
          'submitter_id' : obj.submitter_id,
          'delegate'     : unicode(obj.delegate).encode("utf-8"),
@@ -290,6 +300,7 @@ def patch_list(filter={}):
             "project_id",
             "submitter_id",
             "delegate_id",
+            "archived",
             "state_id",
             "date",
             "commit_ref",
@@ -317,6 +328,9 @@ def patch_list(filter={}):
             elif parts[0] == 'submitter_id':
                 dfilter['submitter'] = Person.objects.filter(id =
                                         filter[key])[0]
+            elif parts[0] == 'delegate_id':
+                dfilter['delegate'] = Person.objects.filter(id =
+                                        filter[key])[0]
             elif parts[0] == 'state_id':
                 dfilter['state'] = State.objects.filter(id =
                                         filter[key])[0]
@@ -368,7 +382,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(True)
     except:
         return ""