summaryrefslogtreecommitdiff
path: root/patchwork/templatetags
diff options
context:
space:
mode:
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>2017-12-19 16:32:03 +1100
committerStephen Finucane <stephen@that.guru>2018-01-04 13:31:28 +0000
commit662400d03222ae46b83d256c0ea7b125a2440752 (patch)
treefa7d9a8338a76b1b36a61552e64151450a120ca5 /patchwork/templatetags
parent79934782a4ca00f193fe2a7340aba6281bed359d (diff)
downloadpatchwork-662400d03222ae46b83d256c0ea7b125a2440752.tar
patchwork-662400d03222ae46b83d256c0ea7b125a2440752.tar.gz
models, templatetags: Make tag count column in patch list optional per tag
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>
Diffstat (limited to 'patchwork/templatetags')
-rw-r--r--patchwork/templatetags/patch.py2
-rw-r--r--patchwork/templatetags/project.py5
2 files changed, 4 insertions, 3 deletions
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('<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])))