示例#1
0
def see_edit(id):
    user = get_model().read(id)

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

        user = get_model().update(data, id)
        print("crud.py line 148")
        print(data)

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

    return render_template("signup.html", action="Edit", user=user)
示例#2
0
def see(id):
    user = get_model().read(id)
    # print(user)
    print("User details are : crud.py:11")
    print(user)
    # print(")))))))))))")
    return render_template("user.html", users=user)
示例#3
0
def view():

    token = request.args.get('page_token', None)
    if token:
        token = token.encode('utf-8')

    users, next_page_token = get_model().list1(cursor=token)

    return render_template("view.html",
                           users=users,
                           next_page_token=next_page_token)
示例#4
0
def login():
    error = None
    if request.method == 'POST':

        user = get_model().nemail(str(request.form['email']))
        if request.form['email'] == user['email'] and request.form[
                'password'] == user['password']:
            if user['admin'] == 'yes':
                return redirect(url_for('crud.view'))
            else:
                return render_template('validuser.html', user=user['email'])
        else:

            return render_template('form.html')
示例#5
0
def signup():
    # print(request.method)
    if request.method == 'POST':
        data = request.form.to_dict(flat=True)
        user = get_model().create(data)
        # print(user)
        url = "https://www.google.com/recaptcha/api/siteverify"
        cap_res = data.get("g-recaptcha-response")
        params = {
            'secret': '6LdUGpIUAAAAAO2ASyVLPqRIYBVDWoeNVXj1ljgm',
            'response': cap_res
        }
        res = requests.post(url, params=params)
        if res.json()['success']:
            return redirect(url_for('crud.form'))

    return render_template("signup.html", action="Signup", user={})
示例#6
0
def delete(id):
    get_model().delete(id)
    return redirect(url_for('.view'))