[PATCH v2 06/10] templates/patch-list: Add patch "checks" column

Stephen Finucane stephen.finucane at intel.com
Fri Oct 2 00:52:30 AEST 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 4b3cb23..4dd37c7 100644
--- a/patchwork/templates/patchwork/patch-list.html
+++ b/patchwork/templates/patchwork/patch-list.html
@@ -78,6 +78,10 @@
    </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 %}"><img
@@ -176,6 +180,7 @@
    <td><a href="{% url 'patchwork.views.patch.patch' patch_id=patch.id %}"
      >{{ patch.name|default:"[no subject]" }}</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 496dcfc..58575e9 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()
 
 
@@ -34,3 +37,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