diff --git a/freepost/__init__.py b/freepost/__init__.py index bc930f5..215c4e3 100755 --- a/freepost/__init__.py +++ b/freepost/__init__.py @@ -476,6 +476,7 @@ def post_thread (hash_id): user = session.user () post = database.get_post (hash_id, user['id'] if user else None) comments = database.get_post_comments (post['id'], user['id'] if user else None) + topics = database.get_post_topics (post['id']) # Group comments by parent comments_tree = {} @@ -520,6 +521,7 @@ def post_thread (hash_id): 'post.html', post=post, comments=comments, + topics=topics, show_source=show_source, votes = { 'post': {}, diff --git a/freepost/database.py b/freepost/database.py index 426fa11..b853725 100644 --- a/freepost/database.py +++ b/freepost/database.py @@ -441,6 +441,24 @@ def get_post_comments (post_id, session_user_id = None): return cursor.fetchall () +# Retrieve all topics for a specific post +def get_post_topics (post_id): + cursor = db.cursor (MySQLdb.cursors.DictCursor) + + cursor.execute ( + """ + SELECT T.name + FROM topic AS T + WHERE T.post_id = %(post)s + ORDER BY T.name ASC + """, + { + 'post': post_id + } + ) + + return cursor.fetchall () + # Submit a new comment to a post def new_comment (comment_text, post_hash_id, user_id, parent_user_id = None, parent_comment_id = None): # Create a hash_id for the new comment diff --git a/freepost/templates/post.html b/freepost/templates/post.html index 06a0a58..0ceb714 100755 --- a/freepost/templates/post.html +++ b/freepost/templates/post.html @@ -25,7 +25,13 @@ {{ post.link|netloc }} {% endif %} - + +
+ {% for topic in topics %} + {{ topic.name }} + {% endfor %} +
+
{{ vote ('post', post, user) }}