summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/templatetags/package_extras.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index ff66a9f2..66ba31a7 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -30,3 +30,25 @@ 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)
+
+ def render(self, context):
+ try:
+ real_user = self.user.resolve(context)
+ # TODO don't hardcode
+ return '<a href="/packages/search/?maintainer=%s">%s</a>' % (
+ real_user.username, real_user.get_full_name())
+ except template.VariableDoesNotExist:
+ return ''
+ pass