Пример #1
0
def dash():
    db = connectToMySQL('joblist')
    job = db.query_db('SELECT * FROM works WHERE granted = 0;')
    db = connectToMySQL('joblist')
    user = db.query_db('SELECT * FROM users;')
    db = connectToMySQL('joblist')
    job1 = db.query_db('SELECT * FROM works WHERE granted = 1;')
    return render_template('dashboard.html', job=job, job1=job1, user=user[0])
Пример #2
0
def makeWishProcess():
    db = connectToMySQL('joblist')
    is_valid = True
    if len(request.form['job']) < 3:
        is_valid = False
        flash("A job must contain 3 characters!")
    if len(request.form['description']) < 3:
        is_valid = False
        flash("A description must contain 3 characters!")
    if len(request.form['location']) < 3:
        is_valid = False
        flash("A location must contain 3 characters!")
    if not is_valid:
        return redirect("/add/job")
    query = "INSERT INTO works (job, description, location, category, worker, created_at, updated_at) VALUES (%(jo)s, %(ds)s, %(lo)s,%(ca)s,%(id)s, NOW(), NOW());"
    data = {
        "jo": request.form['job'],
        "ds": request.form['description'],
        "lo": request.form['location'],
        "ca": request.form['category'],
        "id": session['users']['id']
    }
    print(query)
    print(db)
    db.query_db(query, data)
    return redirect("/dashboard")
Пример #3
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)
Пример #4
0
def display_one_user(user_id):
    print("line 27______", user_id)
    mysql = connectToMySQL('users')
    query = "SELECT * FROM users WHERE id = %(id)s;"
    data = {
        'id': user_id
    }
    user = mysql.query_db(query, data)
    
    return render_template("one_user.html", users=user)
Пример #5
0
def process():
    pw_hash = bcrypt.generate_password_hash(request.form['passCon'])
    print(pw_hash)
    db = connectToMySQL('joblist')
    query = "SELECT * FROM users WHERE email = %(email)s;"
    data = {"email": request.form['email']}
    emailcheck = db.query_db(query, data)
    is_valid = True
    if (len(emailcheck) != 0):
        is_valid = False
        flash("Email address already in use")
    if not EMAIL_REGEX.match(request.form['email']):
        is_valid = False
        flash("Invalid email address!")
    if len(request.form['email']) < 10:
        is_valid = False
        flash("please enter a valid email")
    if len(request.form['fname']) < 2:
        is_valid = False
        flash("Please enter a valid first name")
    if len(request.form['lname']) < 2:
        is_valid = False
        flash("Please enter a valid last name")
    if len(request.form['passCon']) < 8:
        is_valid = False
        flash("Password is too short")
    if (request.form['passCon'] != request.form['passCon2']):
        is_valid = False
        flash("Passwords do not match")
    if not is_valid:
        return redirect("/")
    db = connectToMySQL('joblist')
    query = 'INSERT INTO users(first_name, last_name, email,pw_hash, created_at, updated_at) VALUES (%(fn)s, %(ln)s,%(em)s, %(pwh)s, NOW(), NOW());'
    data = {
        "fn": request.form["fname"],
        "ln": request.form["lname"],
        "em": request.form["email"],
        "pwh": pw_hash
    }
    db.query_db(query, data)
    return redirect("/")
Пример #6
0
def login():
    db = connectToMySQL("joblist")
    query = "SELECT * FROM users WHERE email = %(em)s;"
    data = {"em": request.form["email"]}
    result = db.query_db(query, data)
    if len(result) > 0:
        if bcrypt.check_password_hash(result[0]['pw_hash'],
                                      request.form['passCon']):
            session['users'] = result[0]
            return redirect('/dashboard')
    flash("You could not be logged in")
    return redirect("/")
Пример #7
0
def destroy_user(user_id):
    print("line 27______", user_id)
    mysql = connectToMySQL('users')
    query = """DELETE FROM users.users WHERE
            (id = %(id)s);"""
# UPDATE `users`.`users` SET `first_name` = 'Katrinahfvkjasfdh' WHERE (`id` = '4');

    data = {
        'id': user_id
    }
    mysql.query_db(query, data)

    return redirect("/users")
Пример #8
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)
Пример #9
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);"""
# UPDATE `users`.`users` SET `first_name` = 'Katrinahfvkjasfdh' WHERE (`id` = '4');

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

    return redirect(route_str)
Пример #10
0
def jobEditProcess(id):
    db = connectToMySQL('joblist')
    is_valid = True
    if len(request.form['job']) < 3:
        is_valid = False
        flash("A job must contain 3 characters!")
    if len(request.form['description']) < 3:
        is_valid = False
        flash("A description must contain 3 characters!")
    if len(request.form['location']) < 3:
        is_valid = False
        flash("A location must contain 3 characters!")
    if not is_valid:
        return redirect("/jobs/<id>/edit/")
    query = "UPDATE works SET job = %(jo)s , description = %(ds)s,location = %(lo)s, updated_at = NOW() WHERE id= %(id)s;"

    data = {
        "jo": request.form['job'],
        "ds": request.form['description'],
        "lo": request.form['location'],
        "id": id
    }
    db.query_db(query, data)
    return redirect("/dashboard")
Пример #11
0
def addjobh():
    db = connectToMySQL('joblist')
    db.query_db('SELECT * FROM works;')
    return render_template("addjob.html")
Пример #12
0
def jobview(id):
    db = connectToMySQL('joblist')
    query = "SELECT * FROM works WHERE id = %(id)s;"
    data = {"id": id}
    job = db.query_db(query, data)
    return render_template("viewjob.html", job=job[0])
Пример #13
0
def giveup(id):
    db = connectToMySQL('joblist')
    query = "UPDATE works SET granted = '0', updated_at = NOW() WHERE id = %(id)s;"
    data = {'id': id}
    db.query_db(query, data)
    return redirect("/dashboard")
Пример #14
0
def display_new_user_form():
    mysql = connectToMySQL('users')
    users = mysql.query_db("SELECT * FROM users;")
    return render_template("new_user_form.html", users=users)
Пример #15
0
def home():
    db = connectToMySQL('joblist')
    db.query_db('SELECT * FROM users;')
    return render_template("loginReg.html")
Пример #16
0
def user_delete(id):
    db = connectToMySQL('joblist')
    query = "DELETE FROM works WHERE id = %(id)s;"
    data = {'id': int(id)}
    db.query_db(query, data)
    return redirect("/dashboard")
def display_index():
    mysql = connectToMySQL('pets')
    pets = mysql.query_db("SELECT * FROM pets;")
    return render_template("index.html", pets=pets)
Пример #18
0
def display_all():
    mysql = connectToMySQL('users')
    users = mysql.query_db("SELECT * FROM users;")
    return render_template("index.html", users=users)