summaryrefslogtreecommitdiffhomepage
path: root/apioforum/forum.py
diff options
context:
space:
mode:
Diffstat (limited to 'apioforum/forum.py')
-rw-r--r--apioforum/forum.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py
index f3354c3..a7f4719 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -5,12 +5,14 @@ from flask import (
Blueprint, render_template, request,
g, redirect, url_for, flash, Response
)
+
from .db import get_db
from .mdrender import render
from .thread import post_jump
bp = Blueprint("forum", __name__, url_prefix="/")
+
@bp.route("/")
def view_forum():
db = get_db()
@@ -22,7 +24,15 @@ def view_forum():
GROUP BY threads.id
ORDER BY threads.updated DESC;
""").fetchall()
- return render_template("view_forum.html",threads=threads)
+ thread_tags = {}
+ #todo: somehow optimise this
+ for thread in threads:
+ thread_tags[thread['id']] = db.execute(
+ """SELECT tags.* FROM tags
+ INNER JOIN thread_tags ON thread_tags.tag = tags.id
+ WHERE thread_tags.thread = ?;
+ """,(thread['id'],)).fetchall()
+ return render_template("view_forum.html",threads=threads,thread_tags=thread_tags)
@bp.route("/create_thread",methods=("GET","POST"))
def create_thread():