Merge branch 'extraparams' into lenny
* 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
This commit is contained in:
commit
cf07a446b2
7 changed files with 76 additions and 34 deletions
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# DDPortfolio service DdportfolioController
|
||||
# Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
||||
# Copyright © 2009, 2010 Jan Dittberner <jan@dittberner.info>
|
||||
#
|
||||
# This file is part of DDPortfolio service.
|
||||
#
|
||||
|
@ -90,6 +90,8 @@ developer name on all bug logs)'),
|
|||
'nm' : N_('NM'),
|
||||
'db' : N_('DB'),
|
||||
'alioth' : N_('Alioth'),
|
||||
'wiki' : N_('Wiki'),
|
||||
'forum' : N_('Forum'),
|
||||
},
|
||||
'miscellaneous' : {
|
||||
'label' : N_('Miscellaneous'),
|
||||
|
@ -144,8 +146,6 @@ developer name on all bug logs)'),
|
|||
('nonddemail', 'email')):
|
||||
if not tuple[0] in rp or not rp[tuple[0]]:
|
||||
rp[tuple[0]] = fields[tuple[1]]
|
||||
if not 'mode' in rp or not rp['mode']:
|
||||
rp['mode'] = 'html'
|
||||
|
||||
schema = DeveloperData()
|
||||
try:
|
||||
|
@ -156,8 +156,12 @@ developer name on all bug logs)'),
|
|||
except formencode.validators.Invalid, error:
|
||||
c.messages = { 'errors' : error.unpack_errors() }
|
||||
return render('/showform.mako')
|
||||
data = build_urls(rp)
|
||||
if 'mode' in rp and rp['mode'] == 'json':
|
||||
if form_result['wikihomepage'] is None:
|
||||
log.debug('generate wikihomepage from name')
|
||||
form_result['wikihomepage'] = "".join(
|
||||
[part.capitalize() for part in form_result['name'].split()])
|
||||
data = build_urls(form_result)
|
||||
if form_result['mode'] == 'json':
|
||||
response.headers['Content-Type'] = 'text/javascript'
|
||||
return simplejson.dumps(
|
||||
dict([("%s.%s" % \
|
||||
|
|
|
@ -9,7 +9,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: ddportfolioservice 0.1\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2010-05-10 21:18+0200\n"
|
||||
"POT-Creation-Date: 2010-06-03 22:38+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -162,31 +162,39 @@ msgstr ""
|
|||
msgid "DB"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:95
|
||||
msgid "Miscellaneous"
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:93
|
||||
msgid "Wiki"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:96
|
||||
msgid "debtags"
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:94
|
||||
msgid "Forum"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:97
|
||||
msgid "links"
|
||||
msgid "Miscellaneous"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:98
|
||||
msgid "Debian website"
|
||||
msgid "debtags"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:99
|
||||
msgid "links"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:100
|
||||
msgid "Debian website"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:101
|
||||
msgid "Debian search"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:102
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:104
|
||||
msgid "Ubuntu"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:103
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:105
|
||||
msgid "Available patches from Ubuntu"
|
||||
msgstr ""
|
||||
|
||||
|
@ -214,7 +222,8 @@ msgstr ""
|
|||
msgid "Alioth user name"
|
||||
msgstr ""
|
||||
|
||||
#: ddportfolioservice/model/urlbuilder.py:74
|
||||
#: ddportfolioservice/model/urlbuilder.py:86
|
||||
#: ddportfolioservice/model/urlbuilder.py:90
|
||||
#, python-format
|
||||
msgid "Missing input: %s"
|
||||
msgstr ""
|
||||
|
|
Binary file not shown.
|
@ -9,7 +9,7 @@ msgstr ""
|
|||
"Project-Id-Version: ddportfolioservice 0.1\n"
|
||||
"Report-Msgid-Bugs-To: jan@dittberner.info\n"
|
||||
"POT-Creation-Date: 2009-01-20 23:13+0100\n"
|
||||
"PO-Revision-Date: 2010-05-10 21:20+0200\n"
|
||||
"PO-Revision-Date: 2010-06-03 22:38+0200\n"
|
||||
"Last-Translator: Jan Dittberner <jan@dittberner.info>\n"
|
||||
"Language-Team: de <LL@li.org>\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
|
||||
|
@ -174,32 +174,39 @@ msgstr "NM"
|
|||
msgid "DB"
|
||||
msgstr "DB"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:95
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:93
|
||||
msgid "Wiki"
|
||||
msgstr "Wiki"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:94
|
||||
msgid "Forum"
|
||||
msgstr "Forum"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:97
|
||||
msgid "Miscellaneous"
|
||||
msgstr "Sonstiges"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:96
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:98
|
||||
msgid "debtags"
|
||||
msgstr "debtags"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:97
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:99
|
||||
msgid "links"
|
||||
msgstr "Links"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:98
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:100
|
||||
msgid "Debian website"
|
||||
msgstr "Debian Webseite"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:99
|
||||
#| msgid "Debian user name"
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:101
|
||||
msgid "Debian search"
|
||||
msgstr "Debian-Suche"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:102
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:104
|
||||
msgid "Ubuntu"
|
||||
msgstr "Ubuntu"
|
||||
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:103
|
||||
#: ddportfolioservice/controllers/ddportfolio.py:105
|
||||
msgid "Available patches from Ubuntu"
|
||||
msgstr "Verfügbare Patches aus Ubuntu"
|
||||
|
||||
|
@ -227,7 +234,8 @@ msgstr "Nicht-DD E-Mailadresse:"
|
|||
msgid "Alioth user name"
|
||||
msgstr "Alioth-Benutzername"
|
||||
|
||||
#: ddportfolioservice/model/urlbuilder.py:74
|
||||
#: ddportfolioservice/model/urlbuilder.py:86
|
||||
#: ddportfolioservice/model/urlbuilder.py:90
|
||||
#, python-format
|
||||
msgid "Missing input: %s"
|
||||
msgstr "Fehlende Eingabe: %s"
|
||||
|
|
|
@ -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…
Reference in a new issue