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 deletion
—
download
Diffstat
Diff options
+2/-0
M freepost/__init__.py
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
|
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
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
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
|
|
|