示例#1
0
def create():
    response = {'success': False}
    form = DojoForm(request.form)
    if form.validate():
        dojo = Dojo(name=request.form['name'])
        dojo.save()
        response['dojo_link'] = url_for('.comment', name=dojo.name)
        response['feedback_link'] = url_for('.feedback', name=dojo.name)
        response['success'] = True
    return Response(simplejson.dumps(response), mimetype="application/json")
示例#2
0
文件: views.py 项目: DP6/dojofeedback
def create():
    response = {'success': False}
    form = DojoForm(request.form)
    if form.validate():
        dojo = Dojo(name=request.form['name'])
        host = request.headers['Origin']

        dojo.save()

        response['dojo_link'] = host + url_for('.comment', name=dojo.name)
        response['feedback_link'] = host + url_for('.feedback', name=dojo.name)

        create_qrcode(response['dojo_link'])

        response['success'] = True
    else:
        response['errors'] = []
        for error in form.name.errors:
            response['errors'].append(error)
    return Response(simplejson.dumps(response), mimetype="application/json")