forked from jan/debianmemberportfolio
Merge branch 'extraparams' into pylons0.10
* extraparams: generate wikihomepage from name if parameter is missing add translations for new pattern labels add support for optional patterns support non unicode fields add new patterns for wiki and forum improve handling of missing fields accept extra fields forumsid and wikihomepage use the fixed set of dependency versions from Lenny
This commit is contained in:
commit
74ed088cf9
7 changed files with 75 additions and 32 deletions
|
@ -72,10 +72,13 @@ people.pattern=http://people.debian.org/~%(username)s/
|
|||
alioth.pattern=http://alioth.debian.org/~%(aliothusername)s/
|
||||
|
||||
[membership]
|
||||
urls=nm,db,alioth
|
||||
urls=nm,db,alioth,wiki,forum
|
||||
nm.pattern=https://nm.debian.org/nmstatus.php?email=%(nonddemail)s
|
||||
db.pattern=http://db.debian.org/search.cgi?uid=%(username)s&dosearch=Search
|
||||
alioth.pattern=http://alioth.debian.org/users/%(aliothusername)s/
|
||||
wiki.pattern=http://wiki.debian.org/%(wikihomepage)s
|
||||
forum.pattern=http://forums.debian.net/memberlist.php?mode=viewprofile&u=%(forumsid)d
|
||||
forum.optional=true
|
||||
|
||||
[miscellaneous]
|
||||
urls=debtags,links,website,search
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# DDPortfolio service form handling model
|
||||
# Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
||||
# Copyright © 2009, 2010 Jan Dittberner <jan@dittberner.info>
|
||||
#
|
||||
# This file is part of DDPortfolio service.
|
||||
#
|
||||
|
@ -34,7 +34,10 @@ class DeveloperData(formencode.Schema):
|
|||
username = formencode.validators.PlainText()
|
||||
nonddemail = formencode.validators.Email()
|
||||
aliothusername = formencode.validators.PlainText()
|
||||
mode = formencode.validators.OneOf([u'json', u'html'], not_empty=True)
|
||||
mode = formencode.validators.OneOf([u'json', u'html'], if_missing=u'html')
|
||||
forumsid = formencode.validators.Int(if_missing=None)
|
||||
wikihomepage = formencode.validators.String(if_missing=None)
|
||||
|
||||
|
||||
class DDDataRequest(formencode.Schema):
|
||||
"""Validation schema for DDData request."""
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf8 -*-
|
||||
#
|
||||
# DDPortfolio service url builder
|
||||
# Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
||||
# Copyright © 2009, 2010 Jan Dittberner <jan@dittberner.info>
|
||||
#
|
||||
# This file is part of DDPortfolio service.
|
||||
#
|
||||
|
@ -50,8 +50,16 @@ def build_urls(fields):
|
|||
"""Build personalized URLs using the developer information in
|
||||
fields."""
|
||||
data = []
|
||||
qfields = dict([(key, quote_plus(fields[key].encode('utf8'))) \
|
||||
for key in fields if fields[key] is not None])
|
||||
qfields = {}
|
||||
for key, value in fields.iteritems():
|
||||
if value is not None:
|
||||
if isinstance(value, unicode):
|
||||
qfields[key] = quote_plus(value.encode('utf8'))
|
||||
elif isinstance(value, str):
|
||||
qfields[key] = quote_plus(value)
|
||||
else:
|
||||
qfields[key] = value
|
||||
|
||||
if 'gpgfp' not in qfields:
|
||||
fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8'))
|
||||
if fpr:
|
||||
|
@ -64,13 +72,20 @@ def build_urls(fields):
|
|||
if my_config.has_option(section, 'urls'):
|
||||
for url in my_config.get(section, 'urls').split(','):
|
||||
if my_config.has_option(section, url + '.pattern'):
|
||||
optional = my_config.has_option(section, url + '.optional') \
|
||||
and my_config.getboolean(section, url + '.optional') or False
|
||||
try:
|
||||
data.append(
|
||||
['url', section, url,
|
||||
my_config.get(section, url + '.pattern',
|
||||
False, qfields)])
|
||||
except InterpolationMissingOptionError, e:
|
||||
data.append(['error', section, url,
|
||||
_('Missing input: %s') % \
|
||||
_(_FIELDNAMES_MAP[e.reference])])
|
||||
if not optional:
|
||||
if e.reference in _FIELDNAMES_MAP:
|
||||
data.append(['error', section, url,
|
||||
_('Missing input: %s') % \
|
||||
_(_FIELDNAMES_MAP[e.reference])])
|
||||
else:
|
||||
data.append(['error', section, url,
|
||||
_('Missing input: %s') % e.reference])
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue