summaryrefslogtreecommitdiffstats
path: root/todolists
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-12-28 21:44:09 +0100
committerDan McGee <dan@archlinux.org>2012-12-28 21:48:29 +0100
commitee507a5b81d7a21eaa67da4c848522a5a97d2e3c (patch)
treea48e7b8c27ab27aaa055d40e90efdbfa093a6ad5 /todolists
parent20b64e42672d185821cc584dfa4b133ee259a144 (diff)
downloadarchweb-ee507a5b81d7a21eaa67da4c848522a5a97d2e3c.tar.gz
archweb-ee507a5b81d7a21eaa67da4c848522a5a97d2e3c.tar.xz
Add a todolist package details link template tag
Given the way we retrieve certain related objects, it makes more sense to use a custom tag here rather than our generic package details link tag. When viewing a large todolist, this saves significantly on the number of queries we need to build the page. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'todolists')
-rw-r--r--todolists/templatetags/__init__.py0
-rw-r--r--todolists/templatetags/todolists.py19
2 files changed, 19 insertions, 0 deletions
diff --git a/todolists/templatetags/__init__.py b/todolists/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/todolists/templatetags/__init__.py
diff --git a/todolists/templatetags/todolists.py b/todolists/templatetags/todolists.py
new file mode 100644
index 0000000..5f31dc1
--- /dev/null
+++ b/todolists/templatetags/todolists.py
@@ -0,0 +1,19 @@
+from django import template
+
+register = template.Library()
+
+
+def pkg_absolute_url(repo, arch, pkgname):
+ return '/packages/%s/%s/%s/' % (repo.name.lower(), arch.name, pkgname)
+
+
+@register.simple_tag
+def todopkg_details_link(todopkg):
+ pkg = todopkg.pkg
+ if not pkg:
+ return todopkg.pkgname
+ link = '<a href="%s" title="View package details for %s">%s</a>'
+ url = pkg_absolute_url(todopkg.repo, todopkg.arch, pkg.pkgname)
+ return link % (url, pkg.pkgname, pkg.pkgname)
+
+# vim: set ts=4 sw=4 et: