[PATCH 49/49] patch-list: Tweak how A/R/T tags are displayed

Damien Lespiau damien.lespiau at intel.com
Fri Oct 2 00:12:54 AEST 2015


- Use colors to distinguish the tags
- Don't display any information when there's none (ie don't display
  "there's 0 r-b tag"). That part is something similar to what Thomas
  Petazzoni also did.

v2: Rebase on top of upstream
v3: Tweak a bit the colors

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 htdocs/css/style.css                          | 15 +++++++++++++++
 patchwork/templates/patchwork/patch-list.html | 10 ++++++----
 patchwork/templatetags/patch.py               | 17 +++++++----------
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/htdocs/css/style.css b/htdocs/css/style.css
index 96575df..aa809b3 100644
--- a/htdocs/css/style.css
+++ b/htdocs/css/style.css
@@ -136,6 +136,21 @@ table#patchlist > thead {
     background-color: white;
 }
 
+table#patchlist > tbody > tr > td.tag-A {
+    text-align: center;
+    background-color: #ffe771;
+}
+
+table#patchlist > tbody > tr > td.tag-R {
+    text-align: center;
+    background-color: #c3fd98;
+}
+
+table#patchlist > tbody > tr > td.tag-T {
+    text-align: center;
+    background-color: #b4cfec;
+}
+
 a.colinactive, a.colactive {
 	color: black;
 	text-decoration: none;
diff --git a/patchwork/templates/patchwork/patch-list.html b/patchwork/templates/patchwork/patch-list.html
index c81fe88..ce60a38 100644
--- a/patchwork/templates/patchwork/patch-list.html
+++ b/patchwork/templates/patchwork/patch-list.html
@@ -69,11 +69,11 @@ $(document).ready(function() {
     {% endifequal %}
    </th>
 
+{% for tag in project.tags %}
    <th>
-    <span
-     title="{% for tag in project.tags %}{{tag.name}}{% if not forloop.last %} / {% endif %}{% endfor %}"
-     >{% for tag in project.tags %}{{tag.abbrev}}{% if not forloop.last %}/{% endif %}{% endfor %}</span>
+    <span title="{{tag.name}}">{{tag.abbrev}}</span>
    </th>
+{% endfor %}
 
    <th>
     {% ifequal order.name "date" %}
@@ -153,7 +153,9 @@ $(document).ready(function() {
     {% endif %}
    <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>
+{% for tag in project.tags %}
+   {{ patch|patch_tags:tag }}
+{% endfor %}
    <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..b8a1ed6 100644
--- a/patchwork/templatetags/patch.py
+++ b/patchwork/templatetags/patch.py
@@ -24,13 +24,10 @@ register = template.Library()
 
 
 @register.filter(name='patch_tags')
-def patch_tags(patch):
-    counts = []
-    titles = []
-    for tag in patch.project.tags:
-        count = getattr(patch, tag.attr_name)
-        titles.append('%d %s' % (count, tag.name))
-        counts.append(str(count))
-    return mark_safe('<span title="%s">%s</span>' % (
-        ' / '.join(titles),
-        ' '.join(counts)))
+def patch_tags(patch, tag):
+    count = getattr(patch, tag.attr_name)
+    count_str = str(count) if count else ''
+    class_str = "tag-%s" % tag.abbrev if count else ''
+    title = '%d %s' % (count, tag.name)
+    return mark_safe('<td class="%s"><span title="%s">%s</span></td>' %
+                     (class_str, title, count_str))
-- 
2.1.0



More information about the Patchwork mailing list