From patchwork Tue Dec 19 04:26:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 850583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z15hg6px5z9sQm for ; Tue, 19 Dec 2017 16:15:47 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3z15hg5tDyzDsSj for ; Tue, 19 Dec 2017 16:15:47 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=andrew.donnellan@au1.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3z14dF5WT5zDsR6 for ; Tue, 19 Dec 2017 15:27:45 +1100 (AEDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vBJ4O6ST044270 for ; Mon, 18 Dec 2017 23:27:43 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2exp7uu1c0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 18 Dec 2017 23:27:43 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 19 Dec 2017 04:27:41 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 19 Dec 2017 04:27:38 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vBJ4RcZr61407286; Tue, 19 Dec 2017 04:27:38 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9F37DAE04D; Tue, 19 Dec 2017 04:20:14 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0654DAE045; Tue, 19 Dec 2017 04:20:14 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 19 Dec 2017 04:20:13 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 51B1BA019A; Tue, 19 Dec 2017 15:27:36 +1100 (AEDT) From: Andrew Donnellan To: patchwork@lists.ozlabs.org Subject: [PATCH] models, templatetags: Make tag count column in patch list optional per tag Date: Tue, 19 Dec 2017 15:26:55 +1100 X-Mailer: git-send-email 2.11.0 X-TM-AS-GCONF: 00 x-cbid: 17121904-0040-0000-0000-0000041B9291 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17121904-0041-0000-0000-000020BEB490 Message-Id: <20171219042655.10169-1-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-19_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712190063 X-Mailman-Approved-At: Tue, 19 Dec 2017 16:14:46 +1100 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mpe@ellerman.id.au MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" 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 Closes: #142 ("Ability to add tags that don't also have a column in the UI") Signed-off-by: Andrew Donnellan --- patchwork/fixtures/default_tags.xml | 5 ++++- patchwork/migrations/0021_tag_show_column.py | 20 ++++++++++++++++++++ patchwork/models.py | 3 +++ patchwork/templatetags/patch.py | 2 +- patchwork/templatetags/project.py | 5 +++-- 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 patchwork/migrations/0021_tag_show_column.py diff --git a/patchwork/fixtures/default_tags.xml b/patchwork/fixtures/default_tags.xml index ca5ccfd..baffd43 100644 --- a/patchwork/fixtures/default_tags.xml +++ b/patchwork/fixtures/default_tags.xml @@ -4,15 +4,18 @@ Acked-by ^Acked-by: A + True Reviewed-by ^Reviewed-by: R + True Tested-by ^Tested-by: T + True - \ No newline at end of file + diff --git a/patchwork/migrations/0021_tag_show_column.py b/patchwork/migrations/0021_tag_show_column.py new file mode 100644 index 0000000..9652256 --- /dev/null +++ b/patchwork/migrations/0021_tag_show_column.py @@ -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', '0020_auto_20171219_0333'), + ] + + 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"), + ), + ] diff --git a/patchwork/models.py b/patchwork/models.py index 7d413d9..c48db32 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -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): diff --git a/patchwork/templatetags/patch.py b/patchwork/templatetags/patch.py index c65bd5e..4350e09 100644 --- a/patchwork/templatetags/patch.py +++ b/patchwork/templatetags/patch.py @@ -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: diff --git a/patchwork/templatetags/project.py b/patchwork/templatetags/project.py index 689b486..32d8011 100644 --- a/patchwork/templatetags/project.py +++ b/patchwork/templatetags/project.py @@ -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('%s' % ( - ' / '.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])))