Merge branch 'replies', showing full thread history on reply page
This commit is contained in:
commit
4c1b031ee5
3 changed files with 19 additions and 10 deletions
|
@ -148,8 +148,8 @@ def reply_to_post(post_id):
|
|||
if request.method == "GET":
|
||||
return render_template('reply.html',
|
||||
logged_in=logged_in,
|
||||
reply_to=timeline.post_details(post_id),
|
||||
reply_parent=timeline.get_parent(post_id))
|
||||
posts=timeline.get_full_replies(post_id)[:-1],
|
||||
reply_to=timeline.post_details(post_id))
|
||||
elif request.method == "POST":
|
||||
timeline.post_status(logged_in, request.form['status'], replyTo=post_id)
|
||||
return redirect(url_for('profile'))
|
||||
|
|
|
@ -67,3 +67,12 @@ def get_parent(post_id):
|
|||
return timeline_db.find_one({"_id": timeline_db.find_one({"_id": ObjectId(post_id)})['replyTo']})
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_full_replies(post_id):
|
||||
replies = []
|
||||
replies.append(post_details(post_id))
|
||||
while get_parent(replies[-1]["_id"]):
|
||||
print(replies[-1])
|
||||
replies.append(get_parent(post_id))
|
||||
post_id = get_parent(post_id)['_id']
|
||||
return replies[::-1]
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{% if reply_parent %}
|
||||
<div class="card" style="word-wrap: break-word; margin-bottom: 16px; width: 100%;">
|
||||
<div class="card-header"><b>{{ reply_parent.poster }}</b> at {{ reply_parent.timePosted.strftime('%Y-%m-%d %-H:%M') }}</div>
|
||||
<div class="card-body">
|
||||
{{ reply_parent.content }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for post in posts %}
|
||||
<div class="card" style="word-wrap: brea-word; margin-bottom: 16px; width: 100%;">
|
||||
<div class="card-header"><b>{{ post.poster }}</b> at {{ post.timePosted.strftime('%Y-%m-%d %-H:%M') }}</div>
|
||||
<div class="card-body">
|
||||
{{ post.content }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="card" style="word-wrap: break-word; margin-bottom: 16px; width: 100%;">
|
||||
<div class="card-header">Replying to <b>{{ reply_to.poster }}</b> at {{ reply_to.timePosted.strftime('%Y-%m-%d %-H:%M') }}</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue