summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/templatetags/package_extras.py37
1 files changed, 12 insertions, 25 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index 3cd2b91b..d59a5562 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -31,29 +31,16 @@ def do_buildsortqs(parser, token):
"%r tag's argument should be in quotes" % tagname)
return BuildQueryStringNode(sortfield[1:-1])
-@register.tag
-def userpkgs(parser, token):
- try:
- tagname, user = token.split_contents()
- except ValueError:
- raise template.TemplateSyntaxError(
- "%r tag requires a single argument" % tagname)
- return UserPkgsNode(user)
-
-class UserPkgsNode(template.Node):
- def __init__(self, user):
- self.user = template.Variable(user)
+@register.simple_tag
+def userpkgs(user):
+ if user:
+ # TODO don't hardcode
+ title = escape('View packages maintained by ' + user.get_full_name())
+ return '<a href="/packages/?maintainer=%s" title="%s">%s</a>' % (
+ user.username,
+ title,
+ user.get_full_name(),
+ )
+ return ''
- def render(self, context):
- try:
- real_user = self.user.resolve(context)
- # TODO don't hardcode
- title = escape('View packages maintained by ' + real_user.get_full_name())
- return '<a href="/packages/search/?maintainer=%s" title="%s">%s</a>' % (
- real_user.username,
- title,
- real_user.get_full_name(),
- )
- except template.VariableDoesNotExist:
- return ''
- pass
+# vim: set ts=4 sw=4 et: