forked from jan/debianmemberportfolio
Merge branch 'release/0.5.2'
* release/0.5.2: Bump version to 0.5.2 Strip non hexadecimal characters from GPG fingerprint input Fix issues with incompletely filled forms
This commit is contained in:
commit
b1a9f39c33
4 changed files with 31 additions and 21 deletions
|
@ -28,6 +28,7 @@ from wtforms import IntegerField, StringField, RadioField
|
|||
from wtforms.validators import (
|
||||
AnyOf, DataRequired, Email, Length, Optional, Regexp
|
||||
)
|
||||
from string import hexdigits
|
||||
|
||||
|
||||
class FingerPrint(Regexp):
|
||||
|
@ -40,16 +41,24 @@ class PlainText(Regexp):
|
|||
super(PlainText, self).__init__(r'^[a-zA-Z\-0-9]*$')
|
||||
|
||||
|
||||
def gpg_fingerprint(data):
|
||||
if data is not None:
|
||||
return "".join([
|
||||
char for char in str(data) if char.lower() in hexdigits])
|
||||
return data
|
||||
|
||||
|
||||
class DeveloperData(FlaskForm):
|
||||
email = StringField('email', validators=[DataRequired(), Email()])
|
||||
name = StringField('name', validators=[DataRequired()])
|
||||
gpgfp = StringField('gpgfp', validators=[
|
||||
FingerPrint(),
|
||||
Length(min=32, max=40)
|
||||
name = StringField('name', validators=[Optional(), DataRequired()])
|
||||
gpgfp = StringField('gpgfp', filters=[gpg_fingerprint], validators=[
|
||||
Optional(), FingerPrint(), Length(min=32, max=40)
|
||||
])
|
||||
username = StringField('username', validators=[Optional(), PlainText()])
|
||||
nonddemail = StringField('nonddemail', validators=[Optional(), Email()])
|
||||
aliothusername = StringField('aliothusername', validators=[
|
||||
Optional(), PlainText()
|
||||
])
|
||||
username = StringField('username', validators=[PlainText()])
|
||||
nonddemail = StringField('nonddemail', validators=[Email()])
|
||||
aliothusername = StringField('aliothusername', validators=[PlainText()])
|
||||
mode = RadioField(
|
||||
'mode', default='html', choices=[
|
||||
('json', _('JSON')), ('html', _('HTML'))
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Debian Member Portfolio Service url builder
|
||||
#
|
||||
# Copyright © 2009-2015 Jan Dittberner <jan@dittberner.info>
|
||||
# Copyright © 2009-2017 Jan Dittberner <jan@dittberner.info>
|
||||
#
|
||||
# This file is part of the Debian Member Portfolio Service.
|
||||
#
|
||||
|
@ -73,7 +73,7 @@ def _build_quoted_fields(fields):
|
|||
qfields[key] = quote_plus(value)
|
||||
else:
|
||||
qfields[key] = value
|
||||
qfields[key] = qfields[key].replace('%', '%%')
|
||||
qfields[key] = str(qfields[key]).replace('%', '%%')
|
||||
|
||||
if 'gpgfp' not in qfields:
|
||||
fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8'))
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Debian Member Portfolio Service views
|
||||
#
|
||||
# Copyright © 2015 Jan Dittberner <jan@dittberner.info>
|
||||
# Copyright © 2015-2017 Jan Dittberner <jan@dittberner.info>
|
||||
#
|
||||
# This file is part of the Debian Member Portfolio Service.
|
||||
#
|
||||
|
@ -162,25 +162,26 @@ def urllist():
|
|||
form = DeveloperData(request.values)
|
||||
if form.validate():
|
||||
fields = dddatabuilder.build_data(form.data['email'])
|
||||
rp = request.values
|
||||
|
||||
form_data = form.data.copy()
|
||||
|
||||
if fields['type'] in (dddatabuilder.TYPE_DD, dddatabuilder.TYPE_DM):
|
||||
for dmtuple in DM_TUPLES:
|
||||
if not dmtuple[0] in rp or not rp[dmtuple[0]]:
|
||||
rp[dmtuple[0]] = fields[dmtuple[1]]
|
||||
if not form_data[dmtuple[0]]:
|
||||
form_data[dmtuple[0]] = fields[dmtuple[1]]
|
||||
if fields['type'] == dddatabuilder.TYPE_DD:
|
||||
for ddtuple in DD_TUPLES:
|
||||
if not ddtuple[0] in rp or not rp[ddtuple[0]]:
|
||||
rp[ddtuple[0]] = fields[ddtuple[1]]
|
||||
if form.data['wikihomepage'] is None:
|
||||
if not form_data[ddtuple[0]]:
|
||||
form_data[ddtuple[0]] = fields[ddtuple[1]]
|
||||
if not form_data['wikihomepage']:
|
||||
log.debug('generate wikihomepage from name')
|
||||
form.data['wikihomepage'] = "".join([
|
||||
part.capitalize() for part in form.data['name'].split()
|
||||
form_data['wikihomepage'] = "".join([
|
||||
part.capitalize() for part in form_data['name'].split()
|
||||
])
|
||||
|
||||
data = build_urls(form.data)
|
||||
data = build_urls(form_data)
|
||||
|
||||
if form.data['mode'] == 'json':
|
||||
if form_data['mode'] == 'json':
|
||||
response = make_response(json.dumps(dict(
|
||||
[("{}.{}".format(entry[1], entry[2].name), entry[3])
|
||||
for entry in data if entry[0] == 'url'])))
|
||||
|
|
2
setup.py
2
setup.py
|
@ -29,7 +29,7 @@ except ImportError:
|
|||
|
||||
setup(
|
||||
name='debianmemberportfolio',
|
||||
version='0.5.1',
|
||||
version='0.5.2',
|
||||
description='service to create Debian Member Portfolio URLs',
|
||||
long_description="""This is a service implementation that returns a set of
|
||||
personalized URLs as outlined in https://wiki.debian.org/DDPortfolio. It
|
||||
|
|
Loading…
Reference in a new issue