pre-fill fields if enough necessary information is given
- the email address is enough information for DDs - default to JSON mode - use text/javascript content type for JSON response in ddportfolio controller
This commit is contained in:
parent
2b0b098d1d
commit
6d9b5b85c8
5 changed files with 70 additions and 19 deletions
38
ddportfolioservice/model/dddatabuilder.py
Normal file
38
ddportfolioservice/model/dddatabuilder.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# -*- python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# DDPortfolio service DD data builder
|
||||
# Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
||||
#
|
||||
# This file is part of DDPortfolio service.
|
||||
#
|
||||
# DDPortfolio service is free software: you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Affero General Public License
|
||||
# as published by the Free Software Foundation, either version 3 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# DDPortfolio service is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public
|
||||
# License along with this program. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from ddportfolioservice.model import keyfinder
|
||||
|
||||
|
||||
def build_data(email_address):
|
||||
"""Build a DD data structure from a given email address."""
|
||||
fields = dict([(field, func(str(email_address))) \
|
||||
for (field, func) in \
|
||||
[('gpgfp', keyfinder.getFingerprintByEmail),
|
||||
('name', keyfinder.getRealnameByEmail),
|
||||
('username', keyfinder.getLoginByEmail)]])
|
||||
fields['email'] = email_address
|
||||
if fields['username'] and fields['gpgfp'] and fields['name']:
|
||||
fields['isdd'] = 1
|
||||
else:
|
||||
fields['isdd'] = 0
|
||||
return fields
|
|
@ -38,5 +38,6 @@ class DeveloperData(formencode.Schema):
|
|||
|
||||
class DDDataRequest(formencode.Schema):
|
||||
"""Validation schema for DDData request."""
|
||||
allow_extra_fields = False
|
||||
allow_extra_fields = True
|
||||
filter_extra_fields = False
|
||||
email = formencode.validators.Email(not_empty=True)
|
||||
|
|
|
@ -42,7 +42,7 @@ def _get_keyring_cache():
|
|||
def _get_cached(cachekey):
|
||||
cache = _get_keyring_cache()
|
||||
if cachekey in cache:
|
||||
return cache[cachekey].split(':')
|
||||
return cache[cachekey]
|
||||
return None
|
||||
|
||||
def getFingerprintByEmail(email):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue