summaryrefslogtreecommitdiffhomepage
path: root/apioforum/forum.py
diff options
context:
space:
mode:
Diffstat (limited to 'apioforum/forum.py')
-rw-r--r--apioforum/forum.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py
index 81674a8..98c71f7 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -5,11 +5,13 @@ from flask import (
Blueprint, render_template, request,
g, redirect, url_for, flash
)
+
from .db import get_db
from .mdrender import render
bp = Blueprint("forum", __name__, url_prefix="/")
+
@bp.route("/")
def view_forum():
db = get_db()
@@ -21,7 +23,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():
@@ -77,4 +87,4 @@ def search():
display_thread_id[ix] = False
last_thread = result["thread"]
rendered_posts = [render(q['content']) for q in results]
- return render_template("search_results.html", results=results, query=query, rendered_posts=rendered_posts, display_thread_id=display_thread_id) \ No newline at end of file
+ return render_template("search_results.html", results=results, query=query, rendered_posts=rendered_posts, display_thread_id=display_thread_id)