Merge branch 'replies'
This commit is contained in:
commit
173acbb179
3 changed files with 31 additions and 12 deletions
|
@ -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'))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,19 +1,28 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% 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 %}
|
||||
|
||||
<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>
|
||||
<div class="card-body">
|
||||
{{ reply_to.content }}
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<form method="POST" action="/reply/{{ reply_to._id }}" class="input-group">
|
||||
<input type="text" name="status" style="margin-right: 16px;" class="form-control" value="@{{ reply_to.poster }} " autofocus onfocus="var temp_value=this.value; this.value=''; this.value=temp_value"/>
|
||||
<input type="submit" class="btn btn-primary" value="Do Post" />
|
||||
</form>
|
||||
</div>
|
||||
<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>
|
||||
<div class="card-body">
|
||||
{{ reply_to.content }}
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<form method="POST" action="/reply/{{ reply_to._id }}" class="input-group">
|
||||
<input type="text" name="status" style="margin-right: 16px;" class="form-control" value="@{{ reply_to.poster }} " autofocus onfocus="var temp_value=this.value; this.value=''; this.value=temp_value"/>
|
||||
<input type="submit" class="btn btn-primary" value="Do Post" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Reference in a new issue