home » zplus/freepost.git
Author zPlus <zplus@peers.community> 2019-02-15 19:40:10
Committer zPlus <zplus@peers.community> 2019-02-15 19:40:10
Commit 9358dda (patch)
Tree ea70ff9
Parent(s)

Fix #84 Add list of topics to posts' page.


commits diff: 375a757..9358dda
3 files changed, 27 insertions, 1 deletiondownload


Diffstat
-rwxr-xr-x freepost/__init__.py 2
-rw-r--r-- freepost/database.py 18
-rwxr-xr-x freepost/templates/post.html 8

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+2/-0 M   freepost/__init__.py
index bc930f5..215c4e3
old size: 27K - new size: 27K
@@ -476,6 +476,7 @@ def post_thread (hash_id):
476 476 user = session.user ()
477 477 post = database.get_post (hash_id, user['id'] if user else None)
478 478 comments = database.get_post_comments (post['id'], user['id'] if user else None)
479 + topics = database.get_post_topics (post['id'])
479 480
480 481 # Group comments by parent
481 482 comments_tree = {}
@@ -520,6 +521,7 @@ def post_thread (hash_id):
520 521 'post.html',
521 522 post=post,
522 523 comments=comments,
524 + topics=topics,
523 525 show_source=show_source,
524 526 votes = {
525 527 'post': {},

+18/-0 M   freepost/database.py
index 426fa11..b853725
old size: 19K - new size: 19K
@@ -441,6 +441,24 @@ def get_post_comments (post_id, session_user_id = None):
441 441
442 442 return cursor.fetchall ()
443 443
444 + # Retrieve all topics for a specific post
445 + def get_post_topics (post_id):
446 + cursor = db.cursor (MySQLdb.cursors.DictCursor)
447 +
448 + cursor.execute (
449 + """
450 + SELECT T.name
451 + FROM topic AS T
452 + WHERE T.post_id = %(post)s
453 + ORDER BY T.name ASC
454 + """,
455 + {
456 + 'post': post_id
457 + }
458 + )
459 +
460 + return cursor.fetchall ()
461 +
444 462 # Submit a new comment to a post
445 463 def new_comment (comment_text, post_hash_id, user_id, parent_user_id = None, parent_comment_id = None):
446 464 # Create a hash_id for the new comment

+7/-1 M   freepost/templates/post.html
index 06a0a58..0ceb714
old size: 4K - new size: 5K
@@ -25,7 +25,13 @@
25 25 {{ post.link|netloc }}
26 26 </div>
27 27 {% endif %}
28 -
28 +
29 + <div class="topics">
30 + {% for topic in topics %}
31 + <a href="{{ url ('topic', name=topic.name) }}" class="topic">{{ topic.name }}</a>
32 + {% endfor %}
33 + </div>
34 +
29 35 <div class="info">
30 36 {{ vote ('post', post, user) }}
31 37