Exemple #1
0
def editTest(id):
    test = get_model().read(id)

    if request.method == 'POST':
        data = request.form.to_dict(flat=True)

        test = get_model().update(data, id)

        return redirect(url_for('.view', id=test['id']))

    return render_template("form.html", action="Editing", test=test)
Exemple #2
0
def default():
    token = request.args.get('page_token', None)
    if token:
        token = token.encode('utf-8')

    tests, next_page_token = get_model().list(cursor=token)

    return render_template("home.html",
                           tests=tests,
                           next_page_token=next_page_token)
Exemple #3
0
def listAllTest():
    token = request.args.get('page_token', None)
    if token:
        token = token.encode('utf-8')

    tests, next_page_token = get_model().list_by_user(
        user_id=session['profile']['id'], cursor=token)

    return render_template("list.html",
                           tests=tests,
                           next_page_token=next_page_token)
Exemple #4
0
def addTest():
    if request.method == 'POST':
        data = request.form.to_dict(flat=True)

        if 'profile' in session:
            data['owner'] = session['profile']['displayName']
            data['owner_id'] = session['profile']['id']

        test = get_model().create(data)

        return redirect(url_for('.view', id=test['id']))

    return render_template("form.html", action="Adding", test={})
Exemple #5
0
def deleteTest(id):
    get_model().delete(id)
    return redirect(url_for('.list'))
Exemple #6
0
def viewTest(id):
    test = get_model().read(id)
    return render_template("view.html", test=test)