add support for automatic DM data lookup

This commit is contained in:
Jan Dittberner 2010-06-11 21:42:30 +02:00
parent 556e254870
commit e5a73bfe75
3 changed files with 39 additions and 11 deletions

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
#
# 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.
#
@ -20,8 +20,14 @@
# License along with this program. If not, see
# <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
TYPE_NO = 0
TYPE_DM = 1
TYPE_DD = 2
def build_data(email_address):
"""Build a DD data structure from a given email address."""
@ -32,7 +38,9 @@ def build_data(email_address):
('username', keyfinder.getLoginByEmail)]])
fields['email'] = email_address
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:
fields['isdd'] = 0
fields['type'] = TYPE_NO
return fields