Add result view implementation
This commit implements the result view and template. - fix Python3 configparser interpolation error in portfolio.ini - debianmemberportfolio.model.urlbuilder ported to Python3 - add showurls.html as a direct Jinja port of showurls.mako - implement functionality in debianmemberportfolio.views.result
This commit is contained in:
parent
43ade2d35e
commit
b7fe1328bb
4 changed files with 238 additions and 13 deletions
|
@ -83,7 +83,7 @@ webid.optional=true
|
|||
alioth.pattern=https://alioth.debian.org/users/%(aliothusername)s/
|
||||
alioth.optional=true
|
||||
wiki.pattern=https://wiki.debian.org/%(wikihomepage)s
|
||||
forum.pattern=http://forums.debian.net/memberlist.php?mode=viewprofile&u=%(forumsid)d
|
||||
forum.pattern=http://forums.debian.net/memberlist.php?mode=viewprofile&u=%(forumsid)s
|
||||
forum.optional=true
|
||||
|
||||
[miscellaneous]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Debian Member Portfolio Service url builder
|
||||
#
|
||||
# Copyright © 2009-2014 Jan Dittberner <jan@dittberner.info>
|
||||
# Copyright © 2009-2015 Jan Dittberner <jan@dittberner.info>
|
||||
#
|
||||
# This file is part of the Debian Member Portfolio Service.
|
||||
#
|
||||
|
@ -26,15 +26,18 @@ URLs using the given information and the URL patterns defined in
|
|||
portfolio.ini.
|
||||
"""
|
||||
|
||||
from ConfigParser import ConfigParser, InterpolationMissingOptionError
|
||||
from configparser import ConfigParser, InterpolationMissingOptionError
|
||||
from encodings.utf_8 import StreamReader as UTF8StreamReader
|
||||
|
||||
import pkg_resources
|
||||
from debianmemberportfolio.model import keyfinder
|
||||
from urllib import quote_plus
|
||||
from pylons.i18n.translation import _, N_
|
||||
from urllib.parse import quote_plus
|
||||
from flask.ext.babel import gettext as _, lazy_gettext as N_
|
||||
|
||||
|
||||
my_config = ConfigParser()
|
||||
my_config.readfp(pkg_resources.resource_stream(__name__, 'portfolio.ini'))
|
||||
my_config.read_file(UTF8StreamReader(
|
||||
pkg_resources.resource_stream(__name__, 'portfolio.ini')))
|
||||
|
||||
_FIELDNAMES_MAP = {
|
||||
'email': N_('Email address'),
|
||||
|
@ -62,14 +65,15 @@ def _build_quoted_fields(fields):
|
|||
Take a dictionary of raw field values and quote the values if required.
|
||||
"""
|
||||
qfields = {}
|
||||
for key, value in fields.iteritems():
|
||||
for key, value in fields.items():
|
||||
if value is not None:
|
||||
if isinstance(value, unicode):
|
||||
if isinstance(value, str):
|
||||
qfields[key] = quote_plus(value.encode('utf8'))
|
||||
elif isinstance(value, str):
|
||||
qfields[key] = quote_plus(value)
|
||||
else:
|
||||
qfields[key] = value
|
||||
qfields[key] = qfields[key].replace('%', '%%')
|
||||
|
||||
if 'gpgfp' not in qfields:
|
||||
fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8'))
|
||||
|
@ -97,8 +101,8 @@ def build_urls(fields):
|
|||
data.append(
|
||||
['url', section, entry,
|
||||
my_config.get(section, entry.name + '.pattern',
|
||||
False, qfields)])
|
||||
except InterpolationMissingOptionError, e:
|
||||
raw=False, vars=qfields)])
|
||||
except InterpolationMissingOptionError as e:
|
||||
if not entry.optional:
|
||||
if e.reference in _FIELDNAMES_MAP:
|
||||
data.append(['error', section, entry,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue