forked from jan/debianmemberportfolio
add support for automatic DM data lookup
This commit is contained in:
parent
556e254870
commit
e5a73bfe75
3 changed files with 39 additions and 11 deletions
|
@ -144,12 +144,19 @@ developer name on all bug logs)'),
|
||||||
return render('/showform.mako')
|
return render('/showform.mako')
|
||||||
fields = dddatabuilder.build_data(form_result['email'])
|
fields = dddatabuilder.build_data(form_result['email'])
|
||||||
rp = request.params.copy()
|
rp = request.params.copy()
|
||||||
if fields['isdd']:
|
|
||||||
for tuple in (('name', 'name'),
|
DM_TUPLES = (('name', 'name'),
|
||||||
('gpgfp', 'gpgfp'),
|
('gpgfp', 'gpgfp'),
|
||||||
('username', 'username'),
|
('nonddemail', 'email'))
|
||||||
('aliothusername', 'username'),
|
DD_TUPLES = (('username', 'username'),
|
||||||
('nonddemail', 'email')):
|
('aliothusername', 'username'))
|
||||||
|
|
||||||
|
if fields['type'] in (dddatabuilder.TYPE_DD, dddatabuilder.TYPE_DM):
|
||||||
|
for tuple in DM_TUPLES:
|
||||||
|
if not tuple[0] in rp or not rp[tuple[0]]:
|
||||||
|
rp[tuple[0]] = fields[tuple[1]]
|
||||||
|
if fields['type'] == dddatabuilder.TYPE_DD:
|
||||||
|
for tuple in DD_TUPLES:
|
||||||
if not tuple[0] in rp or not rp[tuple[0]]:
|
if not tuple[0] in rp or not rp[tuple[0]]:
|
||||||
rp[tuple[0]] = fields[tuple[1]]
|
rp[tuple[0]] = fields[tuple[1]]
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# DDPortfolio service DD data builder
|
# DDPortfolio service DD data builder
|
||||||
# Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
# Copyright © 2009, 2010 Jan Dittberner <jan@dittberner.info>
|
||||||
#
|
#
|
||||||
# This file is part of DDPortfolio service.
|
# This file is part of DDPortfolio service.
|
||||||
#
|
#
|
||||||
|
@ -20,8 +20,14 @@
|
||||||
# License along with this program. If not, see
|
# License along with this program. If not, see
|
||||||
# <http://www.gnu.org/licenses/>.
|
# <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
"""This file contains code to build a representation of a person based
|
||||||
|
on keyring data associated to a given email address."""
|
||||||
from ddportfolioservice.model import keyfinder
|
from ddportfolioservice.model import keyfinder
|
||||||
|
|
||||||
|
TYPE_NO = 0
|
||||||
|
TYPE_DM = 1
|
||||||
|
TYPE_DD = 2
|
||||||
|
|
||||||
|
|
||||||
def build_data(email_address):
|
def build_data(email_address):
|
||||||
"""Build a DD data structure from a given email address."""
|
"""Build a DD data structure from a given email address."""
|
||||||
|
@ -32,7 +38,9 @@ def build_data(email_address):
|
||||||
('username', keyfinder.getLoginByEmail)]])
|
('username', keyfinder.getLoginByEmail)]])
|
||||||
fields['email'] = email_address
|
fields['email'] = email_address
|
||||||
if fields['username'] and fields['gpgfp'] and fields['name']:
|
if fields['username'] and fields['gpgfp'] and fields['name']:
|
||||||
fields['isdd'] = 1
|
fields['type'] = TYPE_DD
|
||||||
|
elif fields['name'] and fields['gpgfp']:
|
||||||
|
fields['type'] = TYPE_DM
|
||||||
else:
|
else:
|
||||||
fields['isdd'] = 0
|
fields['type'] = TYPE_NO
|
||||||
return fields
|
return fields
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
<%doc>
|
<%doc>
|
||||||
Helper JavaScript for the data input form.
|
Helper JavaScript for the data input form.
|
||||||
Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
Copyright © 2009, 2010 Jan Dittberner <jan@dittberner.info>
|
||||||
|
|
||||||
This file is part of DDPortfolio service.
|
This file is part of DDPortfolio service.
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ License along with this program. If not, see
|
||||||
</%doc>
|
</%doc>
|
||||||
|
|
||||||
function updateFields(data, textStatus) {
|
function updateFields(data, textStatus) {
|
||||||
if (data.isdd == 1) {
|
if (data.type == 2) { // DD
|
||||||
$('#name').attr('value', data.name).attr('readonly', 'readonly');
|
$('#name').attr('value', data.name).attr('readonly', 'readonly');
|
||||||
$('#gpgfp').attr('value', data.gpgfp);
|
$('#gpgfp').attr('value', data.gpgfp);
|
||||||
$('#username').attr('value', data.username).attr(
|
$('#username').attr('value', data.username).attr(
|
||||||
|
@ -36,6 +36,19 @@ function updateFields(data, textStatus) {
|
||||||
$('#aliothusernamefield').show();
|
$('#aliothusernamefield').show();
|
||||||
|
|
||||||
$('#nonddemail').focus().select();
|
$('#nonddemail').focus().select();
|
||||||
|
} else if (data.type == 1) { // DM
|
||||||
|
$('#name').attr('value', data.name).attr('readonly', 'readonly');
|
||||||
|
$('#gpgfp').attr('value', data.gpgfp);
|
||||||
|
$('#username').attr('value', '');
|
||||||
|
$('#nonddemail').attr('value', data.email).focus();
|
||||||
|
|
||||||
|
$('#namefield').show();
|
||||||
|
$('#gpgfpfield').show();
|
||||||
|
$('#usernamefield').hide();
|
||||||
|
$('#nonddemailfield').hide();
|
||||||
|
$('#aliothusernamefield').show();
|
||||||
|
|
||||||
|
$('#aliothusername').focus().select();
|
||||||
} else {
|
} else {
|
||||||
$('#nonddemail').attr('value', data.email);
|
$('#nonddemail').attr('value', data.email);
|
||||||
$('#name').removeAttr('readonly');
|
$('#name').removeAttr('readonly');
|
||||||
|
|
Loading…
Reference in a new issue