summaryrefslogtreecommitdiffhomepage
path: root/apioforum/forum.py
diff options
context:
space:
mode:
Diffstat (limited to 'apioforum/forum.py')
-rw-r--r--apioforum/forum.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py
index defc5b1..fa6fcc8 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -26,6 +26,7 @@ def view_forum():
ORDER BY threads.updated DESC;
""").fetchall()
thread_tags = {}
+ preview_post = {}
#todo: somehow optimise this
for thread in threads:
thread_tags[thread['id']] = db.execute(
@@ -34,7 +35,15 @@ def view_forum():
WHERE thread_tags.thread = ?
ORDER BY tags.id;
""",(thread['id'],)).fetchall()
- return render_template("view_forum.html",threads=threads,thread_tags=thread_tags)
+ preview_post[thread['id']] = db.execute(
+ """SELECT * FROM posts WHERE thread = ?
+ ORDER BY created DESC;
+ """,(thread['id'],)).fetchone()
+ return render_template("view_forum.html",
+ threads=threads,
+ thread_tags=thread_tags,
+ preview_post=preview_post
+ )
@bp.route("/create_thread",methods=("GET","POST"))
def create_thread():