Implement fetchdddata view
This commit is contained in:
parent
52066eb904
commit
1c86f707fa
2 changed files with 23 additions and 3 deletions
|
@ -33,3 +33,7 @@ class DeveloperData(Form):
|
||||||
forumsid = IntegerField('forumsid', default=None, validators=[Optional()])
|
forumsid = IntegerField('forumsid', default=None, validators=[Optional()])
|
||||||
wikihomepage = StringField('wikihomepage', default=None, validators=[
|
wikihomepage = StringField('wikihomepage', default=None, validators=[
|
||||||
Optional()])
|
Optional()])
|
||||||
|
|
||||||
|
|
||||||
|
class DeveloperDataRequest(Form):
|
||||||
|
email = StringField('email', validators=[DataRequired(), Email()])
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
from debianmemberportfolio import app, babel
|
from debianmemberportfolio import app, babel
|
||||||
from flask import g, make_response, request, render_template
|
from flask import g, make_response, request, render_template, abort
|
||||||
from config import LANGUAGES
|
from config import LANGUAGES
|
||||||
from .forms import DeveloperData
|
from .forms import DeveloperData, DeveloperDataRequest
|
||||||
|
from .model import dddatabuilder
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@babel.localeselector
|
@babel.localeselector
|
||||||
|
@ -39,4 +45,14 @@ def formhelper_js():
|
||||||
|
|
||||||
@app.route('/showformscripts/fetchdddata/')
|
@app.route('/showformscripts/fetchdddata/')
|
||||||
def fetchdddata():
|
def fetchdddata():
|
||||||
return 'dddata'
|
form = DeveloperDataRequest(request.values)
|
||||||
|
if form.validate():
|
||||||
|
fields = dddatabuilder.build_data(form.data['email'])
|
||||||
|
log.debug(fields)
|
||||||
|
response = make_response(json.dumps(fields))
|
||||||
|
response.headers['Content-Type'] = 'application/json'
|
||||||
|
return response
|
||||||
|
abort(
|
||||||
|
400,
|
||||||
|
"\n".join(["%s: %s" % (key, form.errors[key]) for key in form.errors])
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue