diff options
-rw-r--r-- | main/templatetags/pgp.py | 17 | ||||
-rw-r--r-- | templates/public/keys.html | 4 |
2 files changed, 13 insertions, 8 deletions
diff --git a/main/templatetags/pgp.py b/main/templatetags/pgp.py index 581282b4..afad9df2 100644 --- a/main/templatetags/pgp.py +++ b/main/templatetags/pgp.py @@ -3,8 +3,11 @@ from django.conf import settings from django.utils.html import conditional_escape from django.utils.safestring import mark_safe +from devel.models import DeveloperKey + register = template.Library() + def format_key(key_id): if len(key_id) in (8, 20): return u'0x%s' % key_id @@ -40,12 +43,14 @@ def pgp_key_link(key_id, link_text=None): return '<a href="%s" title="PGP key search for %s">%s</a>' % values @register.simple_tag -def user_pgp_key_link(users, key_id): - matched = [user for user in users if user.userprofile.pgp_key and - user.userprofile.pgp_key[-16:] == key_id[-16:]] - if matched and len(matched) == 1: - return pgp_key_link(key_id, matched[0].get_full_name()) - return pgp_key_link(key_id) +def user_pgp_key_link(key_id): + normalized = key_id[-16:] + try: + matching_key = DeveloperKey.objects.select_related( + 'owner').get(key=normalized, owner_id__isnull=False) + except DeveloperKey.DoesNotExist: + return pgp_key_link(key_id) + return pgp_key_link(key_id, matching_key.owner.get_full_name()) @register.filter(needs_autoescape=True) diff --git a/templates/public/keys.html b/templates/public/keys.html index 35bf414c..cf8ac784 100644 --- a/templates/public/keys.html +++ b/templates/public/keys.html @@ -124,8 +124,8 @@ <tbody> {% for sig in cross_signatures %} <tr> - <td>{% user_pgp_key_link active_users sig.signer %}</td> - <td>{% user_pgp_key_link active_users sig.signee %}</td> + <td>{% user_pgp_key_link sig.signer %}</td> + <td>{% user_pgp_key_link sig.signee %}</td> <td>{{ sig.created }}</td> <td>{{ sig.expires|default:"" }}</td> </tr> |