From 16a250750390c3b75aa7c4e43d13f38b806bae9e Mon Sep 17 00:00:00 2001 From: socks Date: Sun, 18 Feb 2018 13:51:49 +0000 Subject: [PATCH] Completed ability to reply to posts --- Tweeder.py | 3 ++- backend/timeline.py | 6 +++--- templates/reply.html | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Tweeder.py b/Tweeder.py index 9e248f5..56171fd 100644 --- a/Tweeder.py +++ b/Tweeder.py @@ -137,7 +137,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)) elif request.method == "POST": - pass + timeline.post_status(logged_in, request.form['status'], replyTo=post_id) + return redirect(url_for('profile')) if __name__ == '__main__': diff --git a/backend/timeline.py b/backend/timeline.py index 19ad761..d3678d3 100644 --- a/backend/timeline.py +++ b/backend/timeline.py @@ -13,8 +13,8 @@ def post_status(username, content, private=False, replyTo=False, location=False) accounts_mentioned = [] for word in content: if word.startswith("@"): - if accounts_db.find({'username': username.lower()}).count > 0: - accounts_mentioned.append() + if accounts_db.find({'username': username.lower()}).count() > 0: + accounts_mentioned.append(word[1:]) status = { 'isRepost': False, @@ -25,7 +25,7 @@ def post_status(username, content, private=False, replyTo=False, location=False) 'likes': [], 'reposts': [], 'replies': [], - 'replyTo': False or replyTo, + 'replyTo': ObjectId(replyTo), 'hashtags': [x for x in content.split() if x.startswith("#")], 'location': False or location, 'private': False or private, diff --git a/templates/reply.html b/templates/reply.html index 094911b..30cf404 100644 --- a/templates/reply.html +++ b/templates/reply.html @@ -8,12 +8,12 @@ {{ reply_to.content }} -{% endblock %} \ No newline at end of file +{% endblock %}