summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-12-22 21:32:45 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-12-22 21:32:45 -0500
commit3b40bcb3fbd21a50faa5cc7a21714c6dab158cb5 (patch)
tree074263e8cfe5ed05e98873dff26c3e4294d75511 /main
parentd3c35bc608b6eaf299e66146e1aab76d43b69211 (diff)
parentecece25814042d262bb7a102b9cbe48fc9c87db4 (diff)
Merge commit 'ecece25' into archweb-generic
Diffstat (limited to 'main')
-rw-r--r--main/templatetags/pgp.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/main/templatetags/pgp.py b/main/templatetags/pgp.py
index e93e5bca..cc080439 100644
--- a/main/templatetags/pgp.py
+++ b/main/templatetags/pgp.py
@@ -3,6 +3,7 @@ from django.conf import settings
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
+from ..utils import cache_function
from devel.models import DeveloperKey
register = template.Library()
@@ -42,15 +43,22 @@ def pgp_key_link(key_id, link_text=None):
values = (url, format_key(key_id), link_text)
return '<a href="%s" title="PGP key search for %s">%s</a>' % values
-@register.simple_tag
-def user_pgp_key_link(key_id):
- normalized = key_id[-16:]
+
+@cache_function(1800)
+def name_for_key(normalized):
try:
matching_key = DeveloperKey.objects.select_related(
'owner').get(key=normalized, owner_id__isnull=False)
+ return matching_key.owner.get_full_name()
except DeveloperKey.DoesNotExist:
- return pgp_key_link(key_id)
- return pgp_key_link(key_id, matching_key.owner.get_full_name())
+ return None
+
+
+@register.simple_tag
+def user_pgp_key_link(key_id):
+ normalized = key_id[-16:]
+ name = name_for_key(normalized)
+ return pgp_key_link(key_id, name)
@register.filter(needs_autoescape=True)