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:
Jan Dittberner 2010-06-03 22:59:25 +02:00
commit cf07a446b2
7 changed files with 76 additions and 34 deletions

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# DDPortfolio service DdportfolioController # 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. # This file is part of DDPortfolio service.
# #
@ -90,6 +90,8 @@ developer name on all bug logs)'),
'nm' : N_('NM'), 'nm' : N_('NM'),
'db' : N_('DB'), 'db' : N_('DB'),
'alioth' : N_('Alioth'), 'alioth' : N_('Alioth'),
'wiki' : N_('Wiki'),
'forum' : N_('Forum'),
}, },
'miscellaneous' : { 'miscellaneous' : {
'label' : N_('Miscellaneous'), 'label' : N_('Miscellaneous'),
@ -144,8 +146,6 @@ developer name on all bug logs)'),
('nonddemail', 'email')): ('nonddemail', 'email')):
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]]
if not 'mode' in rp or not rp['mode']:
rp['mode'] = 'html'
schema = DeveloperData() schema = DeveloperData()
try: try:
@ -156,8 +156,12 @@ developer name on all bug logs)'),
except formencode.validators.Invalid, error: except formencode.validators.Invalid, error:
c.messages = { 'errors' : error.unpack_errors() } c.messages = { 'errors' : error.unpack_errors() }
return render('/showform.mako') return render('/showform.mako')
data = build_urls(rp) if form_result['wikihomepage'] is None:
if 'mode' in rp and rp['mode'] == 'json': 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' response.headers['Content-Type'] = 'text/javascript'
return simplejson.dumps( return simplejson.dumps(
dict([("%s.%s" % \ dict([("%s.%s" % \

View file

@ -9,7 +9,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ddportfolioservice 0.1\n" "Project-Id-Version: ddportfolioservice 0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -162,31 +162,39 @@ msgstr ""
msgid "DB" msgid "DB"
msgstr "" msgstr ""
#: ddportfolioservice/controllers/ddportfolio.py:95 #: ddportfolioservice/controllers/ddportfolio.py:93
msgid "Miscellaneous" msgid "Wiki"
msgstr "" msgstr ""
#: ddportfolioservice/controllers/ddportfolio.py:96 #: ddportfolioservice/controllers/ddportfolio.py:94
msgid "debtags" msgid "Forum"
msgstr "" msgstr ""
#: ddportfolioservice/controllers/ddportfolio.py:97 #: ddportfolioservice/controllers/ddportfolio.py:97
msgid "links" msgid "Miscellaneous"
msgstr "" msgstr ""
#: ddportfolioservice/controllers/ddportfolio.py:98 #: ddportfolioservice/controllers/ddportfolio.py:98
msgid "Debian website" msgid "debtags"
msgstr "" msgstr ""
#: ddportfolioservice/controllers/ddportfolio.py:99 #: 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" msgid "Debian search"
msgstr "" msgstr ""
#: ddportfolioservice/controllers/ddportfolio.py:102 #: ddportfolioservice/controllers/ddportfolio.py:104
msgid "Ubuntu" msgid "Ubuntu"
msgstr "" msgstr ""
#: ddportfolioservice/controllers/ddportfolio.py:103 #: ddportfolioservice/controllers/ddportfolio.py:105
msgid "Available patches from Ubuntu" msgid "Available patches from Ubuntu"
msgstr "" msgstr ""
@ -214,7 +222,8 @@ msgstr ""
msgid "Alioth user name" msgid "Alioth user name"
msgstr "" msgstr ""
#: ddportfolioservice/model/urlbuilder.py:74 #: ddportfolioservice/model/urlbuilder.py:86
#: ddportfolioservice/model/urlbuilder.py:90
#, python-format #, python-format
msgid "Missing input: %s" msgid "Missing input: %s"
msgstr "" msgstr ""

View file

@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: ddportfolioservice 0.1\n" "Project-Id-Version: ddportfolioservice 0.1\n"
"Report-Msgid-Bugs-To: jan@dittberner.info\n" "Report-Msgid-Bugs-To: jan@dittberner.info\n"
"POT-Creation-Date: 2009-01-20 23:13+0100\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" "Last-Translator: Jan Dittberner <jan@dittberner.info>\n"
"Language-Team: de <LL@li.org>\n" "Language-Team: de <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n"
@ -174,32 +174,39 @@ msgstr "NM"
msgid "DB" msgid "DB"
msgstr "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" msgid "Miscellaneous"
msgstr "Sonstiges" msgstr "Sonstiges"
#: ddportfolioservice/controllers/ddportfolio.py:96 #: ddportfolioservice/controllers/ddportfolio.py:98
msgid "debtags" msgid "debtags"
msgstr "debtags" msgstr "debtags"
#: ddportfolioservice/controllers/ddportfolio.py:97 #: ddportfolioservice/controllers/ddportfolio.py:99
msgid "links" msgid "links"
msgstr "Links" msgstr "Links"
#: ddportfolioservice/controllers/ddportfolio.py:98 #: ddportfolioservice/controllers/ddportfolio.py:100
msgid "Debian website" msgid "Debian website"
msgstr "Debian Webseite" msgstr "Debian Webseite"
#: ddportfolioservice/controllers/ddportfolio.py:99 #: ddportfolioservice/controllers/ddportfolio.py:101
#| msgid "Debian user name"
msgid "Debian search" msgid "Debian search"
msgstr "Debian-Suche" msgstr "Debian-Suche"
#: ddportfolioservice/controllers/ddportfolio.py:102 #: ddportfolioservice/controllers/ddportfolio.py:104
msgid "Ubuntu" msgid "Ubuntu"
msgstr "Ubuntu" msgstr "Ubuntu"
#: ddportfolioservice/controllers/ddportfolio.py:103 #: ddportfolioservice/controllers/ddportfolio.py:105
msgid "Available patches from Ubuntu" msgid "Available patches from Ubuntu"
msgstr "Verfügbare Patches aus Ubuntu" msgstr "Verfügbare Patches aus Ubuntu"
@ -227,7 +234,8 @@ msgstr "Nicht-DD E-Mailadresse:"
msgid "Alioth user name" msgid "Alioth user name"
msgstr "Alioth-Benutzername" msgstr "Alioth-Benutzername"
#: ddportfolioservice/model/urlbuilder.py:74 #: ddportfolioservice/model/urlbuilder.py:86
#: ddportfolioservice/model/urlbuilder.py:90
#, python-format #, python-format
msgid "Missing input: %s" msgid "Missing input: %s"
msgstr "Fehlende Eingabe: %s" msgstr "Fehlende Eingabe: %s"

View file

@ -72,10 +72,13 @@ people.pattern=http://people.debian.org/~%(username)s/
alioth.pattern=http://alioth.debian.org/~%(aliothusername)s/ alioth.pattern=http://alioth.debian.org/~%(aliothusername)s/
[membership] [membership]
urls=nm,db,alioth urls=nm,db,alioth,wiki,forum
nm.pattern=https://nm.debian.org/nmstatus.php?email=%(nonddemail)s nm.pattern=https://nm.debian.org/nmstatus.php?email=%(nonddemail)s
db.pattern=http://db.debian.org/search.cgi?uid=%(username)s&amp;dosearch=Search db.pattern=http://db.debian.org/search.cgi?uid=%(username)s&amp;dosearch=Search
alioth.pattern=http://alioth.debian.org/users/%(aliothusername)s/ 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] [miscellaneous]
urls=debtags,links,website,search urls=debtags,links,website,search

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# DDPortfolio service form handling model # 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. # This file is part of DDPortfolio service.
# #
@ -34,7 +34,10 @@ class DeveloperData(formencode.Schema):
username = formencode.validators.PlainText() username = formencode.validators.PlainText()
nonddemail = formencode.validators.Email() nonddemail = formencode.validators.Email()
aliothusername = formencode.validators.PlainText() 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): class DDDataRequest(formencode.Schema):
"""Validation schema for DDData request.""" """Validation schema for DDData request."""

View file

@ -2,7 +2,7 @@
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
# #
# DDPortfolio service url builder # 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. # This file is part of DDPortfolio service.
# #
@ -50,8 +50,16 @@ def build_urls(fields):
"""Build personalized URLs using the developer information in """Build personalized URLs using the developer information in
fields.""" fields."""
data = [] data = []
qfields = dict([(key, quote_plus(fields[key].encode('utf8'))) \ qfields = {}
for key in fields if fields[key] is not None]) 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: if 'gpgfp' not in qfields:
fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8')) fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8'))
if fpr: if fpr:
@ -64,13 +72,20 @@ def build_urls(fields):
if my_config.has_option(section, 'urls'): if my_config.has_option(section, 'urls'):
for url in my_config.get(section, 'urls').split(','): for url in my_config.get(section, 'urls').split(','):
if my_config.has_option(section, url + '.pattern'): 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: try:
data.append( data.append(
['url', section, url, ['url', section, url,
my_config.get(section, url + '.pattern', my_config.get(section, url + '.pattern',
False, qfields)]) False, qfields)])
except InterpolationMissingOptionError, e: except InterpolationMissingOptionError, e:
data.append(['error', section, url, if not optional:
_('Missing input: %s') % \ if e.reference in _FIELDNAMES_MAP:
_(_FIELDNAMES_MAP[e.reference])]) 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 return data