diff options
author | ubq323 <ubq323> | 2021-06-20 23:33:39 +0000 |
---|---|---|
committer | ubq323 <ubq323> | 2021-06-20 23:33:39 +0000 |
commit | df8cdd79dc4c066f2c5c7d754e2c44c8276de93b (patch) | |
tree | e8aac4cb1068dd75b1f68c4f14db1325bfc60e11 | |
parent | 7281e58551e9c1da83cb3e5cfbb910aa97892994 (diff) |
you can create posts again now
-rw-r--r-- | apioforum/forum.py | 11 |
1 files 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("/<int:forum_id>") def view_forum(forum_id): @@ -46,6 +49,10 @@ def view_forum(forum_id): @bp.route("/<int:forum_id>/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( |