Commit e95e7534 authored by Enrico Zini's avatar Enrico Zini
Browse files

Replaced old Person.fpr field with a property that queries the Fingerprint model

parent 8249b9de
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0003_auto_20150829_0905'),
]
operations = [
migrations.RemoveField(
model_name='person',
name='fpr',
),
]
......@@ -485,8 +485,6 @@ class Person(PermissionsMixin, models.Model):
help_text="Please enter here a short biographical information")
# This is null for people who still have not picked one
uid = CharNullField("Debian account name", max_length=32, null=True, unique=True, blank=True)
# OpenPGP fingerprint, NULL until one has been provided
fpr = FingerprintField("OpenPGP key fingerprint", max_length=40, null=True, unique=True, blank=True)
# Membership status
status = models.CharField("current status in the project", max_length=20, null=False,
......@@ -530,6 +528,17 @@ class Person(PermissionsMixin, models.Model):
def has_usable_password(self):
return False
@property
def fpr(self):
"""
Return the current fingerprint for this Person
"""
# TODO: add a way to tell the current valid fingerprints from
# old/revoked ones
for f in self.fprs.all():
return f.fpr
return None
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ["cn", "email", "status"]
......
......@@ -789,13 +789,10 @@ YESNO = (
)
class NewPersonForm(forms.ModelForm):
fpr = forms.CharField(label="Fingerprint", min_length=40, widget=forms.TextInput(attrs={"size": 60}))
sc_ok = forms.ChoiceField(choices=YESNO, widget=forms.RadioSelect(), label="SC and DFSG agreement")
dmup_ok = forms.ChoiceField(choices=YESNO, widget=forms.RadioSelect(), label="DMUP agreement")
def __init__(self, *args, **kwargs):
super(NewPersonForm, self).__init__(*args, **kwargs)
self.fields["fpr"].required = True
def clean_fpr(self):
return bmodels.FingerprintField.clean_fingerprint(self.cleaned_data['fpr'])
......@@ -813,9 +810,8 @@ class NewPersonForm(forms.ModelForm):
class Meta:
model = bmodels.Person
fields = ["cn", "mn", "sn", "email", "bio", "uid", "fpr"]
fields = ["cn", "mn", "sn", "email", "bio", "uid"]
widgets = {
"fpr": forms.TextInput(attrs={'size': 60}),
"bio": forms.Textarea(attrs={'cols': 80, 'rows': 25}),
}
......
......@@ -188,7 +188,7 @@ class Person(VisitPersonTemplateView):
# Build the form to edit the person
includes = []
if "edit_ldap" in perms:
includes.extend(("cn", "mn", "sn", "email", "uid", "fpr"))
includes.extend(("cn", "mn", "sn", "email", "uid"))
if self.visitor.is_admin:
includes.extend(("status", "fd_comment", "expires", "pending"))
if "edit_bio" in perms:
......
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