Commit 7d8580b4 authored by Dan McGee's avatar Dan McGee
Browse files

Add number of keys signed to master keys page



This really just makes me look bad, but an interesting fact none the
less for people to look at.

Signed-off-by: default avatarDan McGee <dan@archlinux.org>
parent 250fa087
......@@ -24,10 +24,8 @@ def __unicode__(self):
class PGPSignature(models.Model):
signer = PGPKeyField(max_length=40, verbose_name="Signer key fingerprint",
help_text="consists of 40 hex digits; use `gpg --fingerprint`")
signee = PGPKeyField(max_length=40, verbose_name="Signee key fingerprint",
help_text="consists of 40 hex digits; use `gpg --fingerprint`")
signer = PGPKeyField(max_length=40, verbose_name="Signer key fingerprint")
signee = PGPKeyField(max_length=40, verbose_name="Signee key fingerprint")
created = models.DateField()
expires = models.DateField(null=True, blank=True)
valid = models.BooleanField(default=True)
......
from django.conf import settings
from django.contrib.auth.models import User
from django.db.models import Count
from django.http import Http404
from django.views.decorators.cache import cache_control
from django.views.generic import list_detail
from django.views.generic.simple import direct_to_template
from devel.models import MasterKey
from devel.models import MasterKey, PGPSignature
from main.models import Arch, Repo, Donor
from mirrors.models import MirrorUrl
from news.models import News
......@@ -87,9 +88,17 @@ def feeds(request):
@cache_control(max_age=300)
def keys(request):
master_keys = MasterKey.objects.select_related('owner', 'revoker',
'owner__userprofile', 'revoker__userprofile').filter(
revoked__isnull=True)
sig_counts = PGPSignature.objects.filter(valid=True,
expires__isnull=True).values_list('signer').annotate(
Count('signer'))
sig_counts = dict((key_id[-16:], ct) for key_id, ct in sig_counts)
for key in master_keys:
key.signature_count = sig_counts.get(key.pgp_key[-16:], 0)
context = {
'keys': MasterKey.objects.select_related('owner', 'revoker',
'owner__userprofile', 'revoker__userprofile').all(),
'keys': master_keys,
}
return direct_to_template(request, 'public/keys.html', context)
......
......@@ -34,13 +34,14 @@ <h2>Master Signing Keys</h2>
<th>Owner's Signing Key</th>
<th>Revoker</th>
<th>Revoker's Signing Key</th>
<th>Developer/TU Keys Signed</th>
</tr>
</thead>
<tbody>
{% for key in keys %}
<tr>
<td>{% pgp_key_link key.pgp_key %}</td>
<td>{{ key.pgp_key|pgp_fingerprint }}</td>
<td><tt>{{ key.pgp_key|pgp_fingerprint }}</tt></td>
{% with key.owner.userprofile as owner_profile %}
<td><a href="{{ owner_profile.get_absolute_url }}">{{ key.owner.get_full_name }}</a></td>
<td>{% pgp_key_link owner_profile.pgp_key %}</td>
......@@ -49,6 +50,7 @@ <h2>Master Signing Keys</h2>
<td><a href="{{ revoker_profile.get_absolute_url }}">{{ key.revoker.get_full_name }}</a></td>
<td>{% pgp_key_link revoker_profile.pgp_key %}</td>
{% endwith %}
<td>{{ key.signature_count }}</td>
</tr>
{% endfor %}
</tbody>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment