Patchwork [2/3] xmlrpc: Export the "to_series" method in patch objects

login
register
mail settings
Submitter Doug Anderson
Date Dec. 30, 2012, 6 a.m.
Message ID <1356847227-8917-3-git-send-email-dianders@chromium.org>
Download mbox | patch
Permalink /patch/208711/
State New
Headers show

Comments

Doug Anderson - Dec. 30, 2012, 6 a.m.
A follow-on CL will add support in pwclient to call this XMLRPC method
to allow listing all of the patches in a series.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 apps/patchwork/views/xmlrpc.py |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

Patch

diff --git a/apps/patchwork/views/xmlrpc.py b/apps/patchwork/views/xmlrpc.py
index a69c858..36ed605 100644
--- a/apps/patchwork/views/xmlrpc.py
+++ b/apps/patchwork/views/xmlrpc.py
@@ -419,6 +419,28 @@  def patch_set(user, patch_id, params):
         raise
 
 @xmlrpc_method(False)
+def patch_to_series(patch_id):
+    """Take a patch ID and return a list of patches in the same series.
+
+    This uses some heuristics to do its job so might not be perfect.
+    See the function in the Patch model for details.
+
+    @patch_id: The patch ID that's part of the series.
+    @return: A list of patches in the series.
+    """
+    # Get the patch.
+    patch = Patch.objects.filter(id=patch_id)
+    if not patch:
+        return []
+    patch = patch[0]
+
+    # Make a series.
+    patches = patch.to_series()
+
+    # Convert to dict for xmlrpc.
+    return [patch_to_dict(p) for p in patches]
+
+@xmlrpc_method(False)
 def state_list(search_str="", max_count=0):
     """Get a list of state structures matching the given search string."""
     try: