diff --git a/Tweeder.py b/Tweeder.py index e86a735..8bdfa6e 100644 --- a/Tweeder.py +++ b/Tweeder.py @@ -135,7 +135,10 @@ def reply_to_post(post_id): if 'username' not in session.keys(): return redirect(url_for('login')) logged_in = session['username'] if ('username' in session.keys()) else False if request.method == "GET": - return render_template('reply.html', logged_in=logged_in, reply_to=timeline.post_details(post_id)) + return render_template('reply.html', + logged_in=logged_in, + reply_to=timeline.post_details(post_id), + reply_parent=timeline.get_parent(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 4c25fbf..c1d7b36 100644 --- a/backend/timeline.py +++ b/backend/timeline.py @@ -60,3 +60,10 @@ def post_details(post_id): def delete_post(post_id): timeline_db.update_one({"_id": ObjectId(post_id)}, {'$set': {'hidden': True}}) + + +def get_parent(post_id): + if timeline_db.find_one({"_id": timeline_db.find_one({"_id": ObjectId(post_id)})['replyTo']}): + return timeline_db.find_one({"_id": timeline_db.find_one({"_id": ObjectId(post_id)})['replyTo']}) + else: + return False diff --git a/templates/reply.html b/templates/reply.html index 2b3d04d..1af7c7a 100644 --- a/templates/reply.html +++ b/templates/reply.html @@ -1,19 +1,28 @@ {% extends 'layout.html' %} {% block content %}