From 1840416b9e8892a685202f30b4079fd04607151f Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 2 Jun 2011 16:21:08 -0500 Subject: Add a PGP key field on the dev profile Signed-off-by: Dan McGee --- main/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'main/models.py') diff --git a/main/models.py b/main/models.py index 59dc154..926e737 100644 --- a/main/models.py +++ b/main/models.py @@ -1,6 +1,8 @@ from django.db import models +from django.core.validators import RegexValidator from django.contrib.auth.models import User from django.contrib.sites.models import Site +from django.forms import ValidationError from main.utils import cache_function, make_choice from packages.models import PackageRelation @@ -9,6 +11,12 @@ from datetime import datetime from itertools import groupby import pytz +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", @@ -26,6 +34,11 @@ class UserProfile(models.Model): max_length=50, help_text="Required field") other_contact = models.CharField(max_length=100, null=True, blank=True) + pgp_key = models.CharField(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)") 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) -- cgit v1.2.3-24-g4f1b