]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
models, templatetags: Make tag count column in patch list optional per tag
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Tue, 19 Dec 2017 05:32:03 +0000 (16:32 +1100)
committerStephen Finucane <stephen@that.guru>
Thu, 4 Jan 2018 13:31:28 +0000 (13:31 +0000)
Add a field, show_column, to the Tag model to determine whether the tag
gets a tag count column in the patch list view. This allows the creation of
tags that will be collated when generating mboxes but won't take up space
in the patch list.

show_column will default to True to maintain the current behaviour by
default.

Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Closes: #142 ("Ability to add tags that don't also have a column in the UI")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/fixtures/default_tags.xml
patchwork/migrations/0020_tag_show_column.py [new file with mode: 0644]
patchwork/models.py
patchwork/templatetags/patch.py
patchwork/templatetags/project.py

index ca5ccfd5a2174bd54acfc9c940b8d80f4d593d2e..baffd43cf5203041a8164d62b6d3c0f7accc9452 100644 (file)
@@ -4,15 +4,18 @@
     <field type="CharField" name="name">Acked-by</field>
     <field type="CharField" name="pattern">^Acked-by:</field>
     <field type="CharField" name="abbrev">A</field>
+    <field type="BooleanField" name="show_column">True</field>
   </object>
   <object pk="2" model="patchwork.tag">
     <field type="CharField" name="name">Reviewed-by</field>
     <field type="CharField" name="pattern">^Reviewed-by:</field>
     <field type="CharField" name="abbrev">R</field>
+    <field type="BooleanField" name="show_column">True</field>
   </object>
   <object pk="3" model="patchwork.tag">
     <field type="CharField" name="name">Tested-by</field>
     <field type="CharField" name="pattern">^Tested-by:</field>
     <field type="CharField" name="abbrev">T</field>
+    <field type="BooleanField" name="show_column">True</field>
   </object>
-</django-objects>
\ No newline at end of file
+</django-objects>
diff --git a/patchwork/migrations/0020_tag_show_column.py b/patchwork/migrations/0020_tag_show_column.py
new file mode 100644 (file)
index 0000000..62fe80a
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.8 on 2017-12-19 04:03
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('patchwork', '0019_userprofile_show_ids'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='tag',
+            name='show_column',
+            field=models.BooleanField(default=True, help_text=b"Show a column displaying this tag's count in the patch list view"),
+        ),
+    ]
index 7d413d933614371feef39b89c5cf4cda5f5910f1..b746588ea38bb519274d12ee7176bac08740bbc2 100644 (file)
@@ -230,6 +230,9 @@ class Tag(models.Model):
     abbrev = models.CharField(
         max_length=2, unique=True, help_text='Short (one-or-two letter)'
         ' abbreviation for the tag, used in table column headers')
+    show_column = models.BooleanField(help_text='Show a column displaying this'
+                                      ' tag\'s count in the patch list view',
+                                      default=True)
 
     @property
     def attr_name(self):
index c65bd5eae7a3967a8d8349e0fb05a7a825d45c83..4350e092eb802581d7f2bff7553185d48e856bb5 100644 (file)
@@ -34,7 +34,7 @@ register = template.Library()
 def patch_tags(patch):
     counts = []
     titles = []
-    for tag in patch.project.tags:
+    for tag in [t for t in patch.project.tags if t.show_column]:
         count = getattr(patch, tag.attr_name)
         titles.append('%d %s' % (count, tag.name))
         if count == 0:
index 689b486012a3999cbf1c4efbd085faeff47e7652..32d8011b5e2a0c3518c6e84dfeea8fc24461acac 100644 (file)
@@ -28,6 +28,7 @@ register = template.Library()
 
 @register.simple_tag(takes_context=True)
 def project_tags(context):
+    tags = [t for t in context['project'].tags if t.show_column]
     return mark_safe('<span title="%s">%s</span>' % (
-        ' / '.join([tag.name for tag in context['project'].tags]),
-        '/'.join([tag.abbrev for tag in context['project'].tags])))
+        ' / '.join([tag.name for tag in tags]),
+        '/'.join([tag.abbrev for tag in tags])))