]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
templates: Add "download series" links
authorStephen Finucane <stephen@that.guru>
Mon, 9 Jan 2017 11:49:03 +0000 (11:49 +0000)
committerStephen Finucane <stephen@that.guru>
Tue, 4 Apr 2017 15:24:08 +0000 (16:24 +0100)
This will allow users to download entire series including the current
patch. Since a patch can belong to many series a dropdown is used.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
patchwork/templates/patchwork/submission.html
patchwork/tests/test_detail.py

index a5914d78308db69f10de7af55f4b941a115c3a0b..dd1b9e39b9e1803b2262b86fd44bef0e7db88f4f 100644 (file)
@@ -288,6 +288,22 @@ function toggle_div(link_id, headers_id)
   <a href="{% url 'patch-mbox' patch_id=submission.id %}"
    class="btn btn-default" role="button" title="Download patch mbox"
    >mbox</a>
+  {% if submission.series.all|length == 1 %}
+  <a href="{% url 'series-mbox' series_id=submission.latest_series.id %}"
+   class="btn btn-default" role="button"
+   title="Download patch mbox with dependencies">series</a>
+  {% elif submission.series.all|length > 1 %}
+  <button type="button" class="btn btn-default dropdown-toggle"
+   data-toggle="dropdown">
+   series <span class="caret"></span>
+  </button>
+  <ul class="dropdown-menu" role="menu">
+  {% for series in submission.series.all %}
+   <li><a href="{% url 'series-mbox' series_id=series.id %}"
+    >{{ series }}</a></li>
+  {% endfor %}
+  </ul>
+  {% endif %}
  </div>
 </h2>
 
index cf2969192f6604b84f53aea85835b240893ab777..ef93bbf0f951fae22e3e36cb603c8efc1dff195f 100644 (file)
@@ -25,6 +25,7 @@ from django.test import TestCase
 from patchwork.tests.utils import create_comment
 from patchwork.tests.utils import create_cover
 from patchwork.tests.utils import create_patch
+from patchwork.tests.utils import create_series
 
 
 class CoverLetterViewTest(TestCase):
@@ -50,6 +51,21 @@ class PatchViewTest(TestCase):
         response = self.client.get(requested_url)
         self.assertRedirects(response, redirect_url)
 
+    def test_series_dropdown(self):
+        patch = create_patch()
+        series = [create_series() for x in range(5)]
+
+        for series_ in series:
+            series_.add_patch(patch, 1)
+
+        response = self.client.get(
+            reverse('patch-detail', kwargs={'patch_id': patch.id}))
+
+        for series_ in series:
+            self.assertContains(
+                response,
+                reverse('series-mbox', kwargs={'series_id': series_.id}))
+
 
 class CommentRedirectTest(TestCase):