Beispiel #1
0
def view_post(username):

    model.connect_to_db()
    post_text = request.form.get('post_text')
    author_id = session.get('user_id')
    owner_id = model.get_user_id_by_username(username)
    model.insert_post(owner_id, author_id, post_text)
    return redirect(url_for("view_user", username = username))
Beispiel #2
0
def view_post(username):

    model.connect_to_db()
    post_text = request.form.get('post_text')
    author_id = session.get('user_id')
    datetime_object = datetime.now()
    created_at = datetime_object.strftime('%m-%d-%Y, %H:%M')
    owner_id = model.get_user_id_by_username(username)
    model.insert_post(owner_id, author_id, created_at, post_text)
    model.CONN.close()

    return redirect(url_for("view_user", username = username))
Beispiel #3
0
def view_user(username):

    model.connect_to_db()

    owner_id = model.get_user_id_by_username(username)
    posts = model.get_posts_by_user_id(owner_id)
    if owner_id != None:
        model.CONN.close()
        return render_template("view_user.html", username = username,
                                                posts = posts)
    else:
        flash("User not found")
        return redirect(url_for("index"))
Beispiel #4
0
def register():
    model.connect_to_db()
    #check if username already exists in db
        #throw and error
    submitted_username = request.form.get('username')
    print "**************************", submitted_username
    submitted_password = request.form.get('password')
    submitted_password_verify = request.form.get('password_verify')
    if model.get_user_id_by_username(submitted_username) != None:
        flash("Username already exists")
        model.CONN.close()
        return redirect(url_for("get_registration_info"))
    else:
        if submitted_password != submitted_password_verify:
            flash("Passwords do not match")
            model.CONN.close()
            return redirect(url_for("get_registration_info"))
        else: 
            model.insert_user(submitted_username, hash(submitted_password))
            model.CONN.close()
            return redirect(url_for("view_user", username=submitted_username))