summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-08-21 07:10:12 +0200
committerDan McGee <dan@archlinux.org>2012-08-21 07:12:20 +0200
commit90001d9ac781d07feba6120bfe64112481b9a5fb (patch)
treeb89e8d1e99bffd4db9c2b140fe2b9ef396aac8e6
parent1c416b97e6a9f3d6bf5f8747bd10ed1ca9cad68c (diff)
downloadarchweb-90001d9ac781d07feba6120bfe64112481b9a5fb.tar.gz
archweb-90001d9ac781d07feba6120bfe64112481b9a5fb.tar.xz
Style cleanups in package_extras
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--packages/templatetags/package_extras.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index 9daecd9..1aedf67 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -9,6 +9,7 @@ from django.utils.html import escape
register = template.Library()
+
def link_encode(url, query):
# massage the data into all utf-8 encoded strings first, so urlencode
# doesn't barf at the data we pass it
@@ -16,6 +17,7 @@ def link_encode(url, query):
data = urlencode(query).replace('&', '&amp;')
return "%s?%s" % (url, data)
+
@register.filter
def url_unquote(original_url):
try:
@@ -27,6 +29,7 @@ def url_unquote(original_url):
except UnicodeError:
return original_url
+
class BuildQueryStringNode(template.Node):
def __init__(self, sortfield):
self.sortfield = sortfield
@@ -34,7 +37,7 @@ class BuildQueryStringNode(template.Node):
def render(self, context):
qs = parse_qs(context['current_query'])
- if qs.has_key('sort') and self.sortfield in qs['sort']:
+ if 'sort' in qs and self.sortfield in qs['sort']:
if self.sortfield.startswith('-'):
qs['sort'] = [self.sortfield[1:]]
else:
@@ -43,6 +46,7 @@ class BuildQueryStringNode(template.Node):
qs['sort'] = [self.sortfield]
return urlencode(qs, True).replace('&', '&amp;')
+
@register.tag(name='buildsortqs')
def do_buildsortqs(parser, token):
try:
@@ -55,15 +59,18 @@ def do_buildsortqs(parser, token):
"%r tag's argument should be in quotes" % tagname)
return BuildQueryStringNode(sortfield[1:-1])
+
@register.simple_tag
def pkg_details_link(pkg):
link = '<a href="%s" title="View package details for %s">%s</a>'
return link % (pkg.get_absolute_url(), pkg.pkgname, pkg.pkgname)
+
@register.simple_tag
def multi_pkg_details(pkgs):
return ', '.join([pkg_details_link(pkg) for pkg in pkgs])
+
@register.simple_tag
def maintainer_link(user):
if user:
@@ -76,6 +83,7 @@ def maintainer_link(user):
)
return ''
+
@register.simple_tag
def packager_link(user):
if user:
@@ -97,6 +105,7 @@ def scm_link(package, operation):
"h=packages/%s")
return linkbase % tuple(urlquote(part) for part in parts)
+
@register.simple_tag
def get_wiki_link(package):
url = "https://wiki.archlinux.org/index.php/Special:Search"
@@ -105,6 +114,7 @@ def get_wiki_link(package):
}
return link_encode(url, data)
+
@register.simple_tag
def bugs_list(package):
url = "https://bugs.archlinux.org/"
@@ -115,6 +125,7 @@ def bugs_list(package):
}
return link_encode(url, data)
+
@register.simple_tag
def bug_report(package):
url = "https://bugs.archlinux.org/newtask"