Example #1
0
def desplay_edit_page(user_id):
    mysql = connectToMySQL('users')
    query = "SELECT * FROM users WHERE id = %(id)s;"
    data = {'id': user_id}
    users = mysql.query_db(query, data)
    user = users[0]

    return render_template("edit_user.html", user=user)
Example #2
0
def display_one_user(user_id):
    print("line 27______", user_id)
    mysql = connectToMySQL('users')
    query = "SELECT * FROM users.users WHERE id = %(id)s;"
    data = {'id': user_id}
    user = mysql.query_db(query, data)

    return render_template("one_user.html", users=user)
Example #3
0
def add_user():
    mysql = connectToMySQL('users')
    query = """INSERT INTO users.users 
                (first_name, last_name, email, created_at, updated_at) 
                VALUES (%(fn)s, %(ln)s, %(em)s, NOW(), NOW());"""
    data = {
        'fn': request.form['fname'],
        'ln': request.form['lname'],
        'em': request.form['email']
    }
    user_id = mysql.query_db(query, data)
    route_str = "/users/" + str(user_id)

    return redirect(route_str)
Example #4
0
def edit_user(user_id):
    print("line 27______", user_id)
    mysql = connectToMySQL('users')
    query = """UPDATE users.users 
            SET first_name=%(fn)s, last_name=%(ln)s, email=%(em)s, updated_at = NOW(), 
            WHERE id = %(id)s;"""

    data = {
        'id': user_id,
        'fn': request.form['fname'],
        'ln': request.form['lname'],
        'em': request.form['email']
    }
    user_id = mysql.query_db(query, data)
    print(user_id)
    route_str = "/users/" + str(user_id)

    return redirect(route_str)
Example #5
0
def display_new_user_form():
    mysql = connectToMySQL('users')
    users = mysql.query_db("SELECT * FROM users.users;")
    return render_template("new_user_form.html", users=users)
Example #6
0
def display_all():
    mysql = connectToMySQL('users')
    users = mysql.query_db("SELECT * FROM users.users;")
    return render_template("index.html", users=users)