Skip to content

Commit 4a7c3f1

Browse files
Raxel Gutierrezdaxtens
authored andcommitted
templatetags: add utils template filters and tags
Add utils.py file to create template filters and tags that can be used by most if not all objects in Patchwork. In particular, add a template filter to get the plural verbose name of a model and add a template tag that returns whether an object is editable by the current user. These utilities will be used in an upcoming patch that adds the `addressed` status label to patch and cover comments. Signed-off-by: Raxel Gutierrez <raxel@google.com> Reviewed-by: Stephen Finucane <stephen@that.guru> Signed-off-by: Daniel Axtens <dja@axtens.net>
1 parent 38959ba commit 4a7c3f1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

patchwork/templatetags/utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Patchwork - automated patch tracking system
2+
# Copyright (C) 2021 Google LLC
3+
#
4+
# SPDX-License-Identifier: GPL-2.0-or-later
5+
6+
from django import template
7+
8+
register = template.Library()
9+
10+
11+
@register.filter
12+
def verbose_name_plural(obj):
13+
return obj._meta.verbose_name_plural
14+
15+
16+
@register.simple_tag
17+
def is_editable(obj, user):
18+
return obj.is_editable(user)

0 commit comments

Comments
 (0)