From df8cdd79dc4c066f2c5c7d754e2c44c8276de93b Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sun, 20 Jun 2021 23:33:39 +0000 Subject: you can create posts again now --- apioforum/forum.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apioforum/forum.py b/apioforum/forum.py index 3022507..e2e5474 100644 --- a/apioforum/forum.py +++ b/apioforum/forum.py @@ -13,6 +13,9 @@ from sqlite3 import OperationalError bp = Blueprint("forum", __name__, url_prefix="/") +@bp.route("/") +def not_actual_index(): + return redirect("/1") @bp.route("/") def view_forum(forum_id): @@ -46,6 +49,10 @@ def view_forum(forum_id): @bp.route("//create_thread",methods=("GET","POST")) def create_thread(forum_id): db = get_db() + forum = db.execute("SELECT * FROM forums WHERE id = ?",(forum_id,)).fetchone() + if forum is None: + flash("that forum doesn't exist") + return redirect(url_for('index')) if g.user is None: flash("you need to be logged in to create a thread") @@ -61,8 +68,8 @@ def create_thread(forum_id): if err is None: cur = db.cursor() cur.execute( - "INSERT INTO threads (title,creator,created,updated) VALUES (?,?,current_timestamp,current_timestamp);", - (title,g.user) + "INSERT INTO threads (title,creator,created,updated,forum) VALUES (?,?,current_timestamp,current_timestamp,?);", + (title,g.user,forum_id) ) thread_id = cur.lastrowid cur.execute( -- cgit v1.2.3