Exemplo n.º 1
0
def delete_board(board_id):
    get_data()
    print(board_id)
    query = f"UPDATE boards SET status=false WHERE board_id={board_id}"
    cur.execute(query)
    conn.commit()
    return redirect(url_for('boardnotes.board'))
Exemplo n.º 2
0
def add_board():
    get_data()
    user_id = user['user_id']
    board_name = request.form['board_name']
    board_desc = request.form['board_desc']
    data = {'board_name': board_name, 'board_desc': board_desc}
    query = f"INSERT INTO boards(board_name, description, status, cover_img, user_id) VALUES ('{board_name}', '{board_desc}', TRUE, NULL, {user_id})"
    cur.execute(query)
    conn.commit()
    return jsonify(data)
Exemplo n.º 3
0
def rename_board():
    get_data()
    boardid = request.form['board_id']
    boardname = request.form['board_name']
    boarddesc = request.form['board_desc']
    data = {'board_name': boardname, 'board_desc': boarddesc}
    query = f"UPDATE boards SET board_name = '{boardname}', description = '{boarddesc}' WHERE board_id={boardid}"
    cur.execute(query)
    conn.commit()
    return jsonify(data)
Exemplo n.º 4
0
def delete_page(page_id):
    get_data()
    query = f"UPDATE pages SET status=false WHERE page_id={page_id}"
    cur.execute(query)
    conn.commit()
    query = f"SELECT board_id from pages where page_id='{page_id}'"
    cur.execute(query)
    board_id = cur.fetchall()[0][0]
    print(board_id)
    return redirect(url_for('boardnotes.page', board_id=board_id))
Exemplo n.º 5
0
def add_page():
    get_data()
    page_name = request.form['page_name']
    # page_data = request.form['page_data']
    board_id = request.form['board_id']
    data = {'page_name': page_name}
    query = f"INSERT INTO pages(page_name, board_id) VALUES ('{page_name}', {board_id})"
    cur.execute(query)
    conn.commit()
    return jsonify(data)
Exemplo n.º 6
0
def profile():
    load_user(user['user_id'])
    form = EditProfileForm(request.form)
    if request.method == 'POST':
        # profile_photo = request.files["image"]
        query = [
            user['user_id'], '', form.profile_name.data, form.profile_bio.data,
            form.fb_handle.data, form.twitter_handle.data, form.ig_handle.data,
            form.linkedIn_handle.data, form.github_handle.data,
            hash_password(form.pwd.data),
            hash_password(form.pwd_repeat.data)
        ]
        print(query)
        final_pwd = ''
        if form.pwd.data == form.pwd_repeat.data and (
                form.pwd.data != '' or form.pwd.data is not None):
            final_pwd = form.pwd.data

        cur.callproc('user_profile_updates', [
            user['user_id'],
            '',
            form.profile_name.data,
            form.profile_bio.data,
            form.fb_handle.data,
            form.twitter_handle.data,
            form.ig_handle.data,
            form.linkedIn_handle.data,
            form.github_handle.data,
            hash_password(final_pwd),
        ])
        temp = cur.fetchall()
        conn.commit()
        return redirect(url_for('useraccounts.profile'))

    cur.callproc('get_active_months', [
        user['user_id'],
    ])
    temp = cur.fetchall()
    month = [temp]
    month = list(dict.fromkeys(month[0]))

    cur.callproc('get_logs', [
        user['user_id'],
    ])
    temp = cur.fetchall()
    data = [temp]

    logs = {'month': month, 'data': data}

    return render_template('profile.html',
                           title='Profile',
                           user=user,
                           user_boards=user_boards,
                           user_pages=user_pages,
                           logs=logs)
Exemplo n.º 7
0
def add_page_data(page_id):
    get_data()
    form = AddPageForm(request.form)
    page_name = form.page_name.data
    page_data = form.page_data.data
    data = {'page_id': page_id, 'page_name': page_name, 'page_data': page_data}
    query = f"UPDATE pages SET page_data='{page_data}',page_name='{page_name}' WHERE page_id='" \
            f"{page_id}';"
    cur.execute(query)
    conn.commit()
    query = f"SELECT board_id from pages where page_id='{page_id}'"
    cur.execute(query)
    board_id = cur.fetchall()[0][0]
    print(board_id)
    return redirect(url_for('boardnotes.page', board_id=board_id))
Exemplo n.º 8
0
def recover_password():
    form = RecoverPasswordForm(request.form)
    if request.method == 'POST' and form.check_email(form.email.data):
        lettersAndDigits = string.ascii_letters + string.digits
        pwd = ''.join(random.choice(lettersAndDigits) for i in range(16))
        print(pwd)
        try:
            query = f"UPDATE Users SET pwd='{hash_password(pwd)}' WHERE email_id = '{form.email.data}'"
            cur.execute(query)
            conn.commit()
        except:
            print('No account is linked to this email')
        return redirect(url_for('useraccounts.login'))
    return render_template('recover_password.html',
                           title='Recover Password',
                           form=form)
Exemplo n.º 9
0
def signup():
    print(request.form.get('dob'))
    form = SignUpForm(request.form)
    if request.method == 'POST' and form.check_username(
            form.username.data) and form.check_email(
                form.email.data) and valid_email(
                    form.email.data) and form.check_passwords(
                        form.pwd.data,
                        form.pwd_confirm.data) and form.check_name(
                            form.name.data):
        try:
            query = f"INSERT INTO Users(username, pwd, email_id, user_name, birth_date) VALUES ('{form.username.data}', '{hash_password(form.pwd.data)}', '{form.email.data}', '{form.name.data}', '{form.dob.data}')"
            cur.execute(query)
            conn.commit()
            return redirect(url_for('useraccounts.login'))
        except:
            print('User Already exists')
    return render_template('signup.html', title='Sign Up', form=form)