[PATCH v3 5/8] templates/patch-list: Add patch "checks" column

Stephen Finucane stephen.finucane at intel.com
Fri Nov 6 04:13:20 AEDT 2015


Add a column to display the important "checks" fields for each patch.
Note that only the "completed" checks are shown (i.e. "in progress" and
"not started" checks are ignored).

Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
---
 patchwork/templates/patchwork/patch-list.html |  5 +++++
 patchwork/templatetags/patch.py               | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/patchwork/templates/patchwork/patch-list.html b/patchwork/templates/patchwork/patch-list.html
index c81fe88..165b079 100644
--- a/patchwork/templates/patchwork/patch-list.html
+++ b/patchwork/templates/patchwork/patch-list.html
@@ -76,6 +76,10 @@ $(document).ready(function() {
    </th>
 
    <th>
+    <span title="Success / Warning / Fail">S/W/F</span>
+   </th>
+
+   <th>
     {% ifequal order.name "date" %}
      <a class="colactive"
       href="{% listurl order=order.reversed_name %}"><span
@@ -154,6 +158,7 @@ $(document).ready(function() {
    <td><a href="{% url 'patchwork.views.patch.patch' patch_id=patch.id %}"
      >{{ patch.name|default:"[no subject]"|truncatechars:100 }}</a></td>
    <td style="white-space: nowrap;">{{ patch|patch_tags }}</td>
+   <td style="white-space: nowrap;">{{ patch|patch_checks }}</td>
    <td>{{ patch.date|date:"Y-m-d" }}</td>
    <td>{{ patch.submitter|personify:project }}</td>
    <td>{{ patch.delegate.username }}</td>
diff --git a/patchwork/templatetags/patch.py b/patchwork/templatetags/patch.py
index 3b28158..26cfc13 100644
--- a/patchwork/templatetags/patch.py
+++ b/patchwork/templatetags/patch.py
@@ -1,5 +1,6 @@
 # Patchwork - automated patch tracking system
 # Copyright (C) 2008 Jeremy Kerr <jk at ozlabs.org>
+# Copyright (C) 2015 Intel Corporation
 #
 # This file is part of the Patchwork package.
 #
@@ -20,6 +21,8 @@
 from django import template
 from django.utils.safestring import mark_safe
 
+from patchwork.models import Check
+
 register = template.Library()
 
 
@@ -37,3 +40,14 @@ def patch_tags(patch):
     return mark_safe('<span title="%s">%s</span>' % (
         ' / '.join(titles),
         ' '.join(counts)))
+
+
+ at register.filter(name='patch_checks')
+def patch_checks(patch):
+    required = [Check.STATE_SUCCESS, Check.STATE_WARNING, Check.STATE_FAIL]
+    titles = ['Success', 'Warning', 'Fail']
+    counts = patch.check_count
+
+    return mark_safe('<span title="%s">%s</span>' % (
+        ' / '.join(titles),
+        ' '.join([str(counts[state]) for state in required])))
-- 
2.0.0



More information about the Patchwork mailing list