summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/models.py17
-rw-r--r--main/templatetags/pgp.py5
2 files changed, 8 insertions, 14 deletions
diff --git a/main/models.py b/main/models.py
index ec1f0d2c..bdb84624 100644
--- a/main/models.py
+++ b/main/models.py
@@ -36,18 +36,13 @@ class PGPKeyField(models.CharField):
if value.startswith('0x'):
value = value[2:]
value = value.split('/')[-1]
- return value
+ # make all (hex letters) uppercase
+ return value.upper()
def formfield(self, **kwargs):
# override so we don't set max_length form field attribute
return models.Field.formfield(self, **kwargs)
-def validate_pgp_key_length(value):
- if len(value) not in (8, 16, 40):
- raise ValidationError(
- u'Ensure this value has 8, 16, or 40 characters (it has %d).' % len(value),
- 'pgp_key_value')
-
class UserProfile(models.Model):
notify = models.BooleanField(
"Send notifications",
@@ -66,10 +61,10 @@ class UserProfile(models.Model):
help_text="Required field")
other_contact = models.CharField(max_length=100, null=True, blank=True)
pgp_key = PGPKeyField(max_length=40, null=True, blank=True,
- verbose_name="PGP key", validators=[RegexValidator(r'^[0-9A-F]+$',
- "Ensure this value consists of only hex characters.", 'hex_char'),
- validate_pgp_key_length],
- help_text="PGP Key ID or fingerprint (8, 16, or 40 hex digits)")
+ verbose_name="PGP key fingerprint",
+ validators=[RegexValidator(r'^[0-9A-F]{40}$',
+ "Ensure this value consists of 40 hex characters.", 'hex_char')],
+ help_text="consists of 40 hex digits; use `gpg --fingerprint`")
website = models.CharField(max_length=200, null=True, blank=True)
yob = models.IntegerField("Year of birth", null=True, blank=True)
location = models.CharField(max_length=50, null=True, blank=True)
diff --git a/main/templatetags/pgp.py b/main/templatetags/pgp.py
index 956de892..f875c11e 100644
--- a/main/templatetags/pgp.py
+++ b/main/templatetags/pgp.py
@@ -4,7 +4,6 @@ from django.conf import settings
register = template.Library()
def format_key(key_id):
- print len(key_id)
if len(key_id) in (8, 20):
return u'0x%s' % key_id
elif len(key_id) == 40:
@@ -24,7 +23,7 @@ def pgp_key_link(key_id):
return format_key(key_id)
url = 'http://%s/pks/lookup?op=vindex&fingerprint=on&exact=on&search=0x%s' % \
(pgp_server, key_id)
- values = (url, key_id, format_key(key_id))
- return '<a href="%s" title="PGP key search for 0x%s">%s</a>' % values
+ values = (url, format_key(key_id), key_id[-8:])
+ return '<a href="%s" title="PGP key search for %s">0x%s</a>' % values
# vim: set ts=4 sw=4 et: