summaryrefslogtreecommitdiffstats
path: root/main/models.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-02 23:21:08 +0200
committerDan McGee <dan@archlinux.org>2011-06-02 23:21:08 +0200
commit1840416b9e8892a685202f30b4079fd04607151f (patch)
treeaf3ed598458bde0813559417c072e53d4fecdec3 /main/models.py
parentcc4fef23e2b4da4744224f5b2c0dbb679834aa49 (diff)
downloadarchweb-1840416b9e8892a685202f30b4079fd04607151f.tar.gz
archweb-1840416b9e8892a685202f30b4079fd04607151f.tar.xz
Add a PGP key field on the dev profile
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main/models.py')
-rw-r--r--main/models.py13
1 files changed, 13 insertions, 0 deletions
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)