diff --git a/Tweeder.py b/Tweeder.py index eebc29c..d35dd8d 100644 --- a/Tweeder.py +++ b/Tweeder.py @@ -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')) diff --git a/backend/timeline.py b/backend/timeline.py index c1d7b36..2764496 100644 --- a/backend/timeline.py +++ b/backend/timeline.py @@ -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] diff --git a/templates/reply.html b/templates/reply.html index 1af7c7a..578b4ac 100644 --- a/templates/reply.html +++ b/templates/reply.html @@ -2,14 +2,14 @@ {% block content %}
- {% if reply_parent %} -
-
{{ reply_parent.poster }} at {{ reply_parent.timePosted.strftime('%Y-%m-%d %-H:%M') }}
-
- {{ reply_parent.content }} -
-
- {% endif %} + {% for post in posts %} +
+
{{ post.poster }} at {{ post.timePosted.strftime('%Y-%m-%d %-H:%M') }}
+
+ {{ post.content }} +
+
+ {% endfor %}
Replying to {{ reply_to.poster }} at {{ reply_to.timePosted.strftime('%Y-%m-%d %-H:%M') }}