Finishing up on comment functionality

This commit is contained in:
Sander Ferdinand 2018-07-02 23:14:10 +02:00
parent 863e91e3f2
commit 40b95ad57d
8 changed files with 208 additions and 64 deletions

View file

@ -0,0 +1,40 @@
{% extends "base.html" %}
{% block content %}
<!-- Page Content -->
<div class="container" style="margin-bottom:140px;">
{% include 'messages.html' %}
<div class="row">
<!-- Post Content Column -->
<div class="col-lg-12">
<div class="proposal_content">
<!-- Post Content -->
<div class="media mb-4">
<div class="votearrow" title="upvote"></div>
<div class="media-body">
<span class="username"><a href="/user/{{ c.user.username }}">{{c.user.username}}</a></span>
<span class="date_posted">{{c.date_added.strftime('%Y-%m-%d %H:%M')}}</span><br>
{{c.message}}
<br><br>
{% if logged_in %}
<form method="post" action="{{url_for('proposal_comment')}}">
<input type="hidden" name="pid" value="{{pid}}">
<input type="hidden" name="cid" value="{{cid}}">
<textarea class="comment" name="text" rows="6" cols="60"></textarea>
<br><br><input type="submit" value="add comment">
</form>
{% else %}
You need to be logged in to comment.
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.container -->
{% endblock %}

View file

@ -1,63 +1,61 @@
<div class="row">
<div class="col-md-12">
<div class="card my-6" id="incoming_txs">
<h5 class="card-header">Comments</h5>
<h5 id="comments" class="card-header">Comments</h5>
<div class="card-body">
{% if logged_in %}
<form method="post" action="comment">
<input type="hidden" name="proposal_id" value="{{proposal.id}}">
<input type="hidden" name="pid" value="{{proposal.id}}">
<textarea class="comment" name="text" rows="6" cols="60"></textarea>
<br><br><input type="submit" value="add comment">
</form>
{% else %}
You need to be logged in to comment.<br>
Press <b>F</b> to pay respects.
You need to be logged in to comment.
<br>
{% endif %}
<br>
{% for c in proposal._comments %}
<!-- Single Comment -->
<div class="media mb-4">
<img class="d-flex mr-3 rounded-circle" src="http://placehold.it/50x50" alt="">
<div class="media mb-4 comment-container" id="comment-{{c.id}}">
<div class="votearrow" title="upvote"></div>
<div class="media-body">
<h5 class="mt-0">Commenter Name</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras
purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi
vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</div>
<span class="username">
<a class="{% if c.user.username == proposal.user.username %}author{% endif %}" href="/user/{{ c.user.username }}">
{{c.user.username}}
</a>
</span>
<span class="date_posted">
<a href="/proposal/{{proposal.id}}#comment-{{c.id}}">
{{c.date_added.strftime('%Y-%m-%d %H:%M')}}
</a>
</span><br>
{{c.message}}
<br>
<a class="reply" href="{{url_for('propsal_comment_reply', cid=c.id, pid=proposal.id)}}">reply</a>
<!-- Comment with nested comments -->
<div class="media mb-4">
<img class="d-flex mr-3 rounded-circle" src="http://placehold.it/50x50" alt="">
<div class="media-body">
<h5 class="mt-0">Commenter Name</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras
purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi
vulputate fringilla. Donec lacinia congue felis in faucibus.
<div class="media mt-4">
<img class="d-flex mr-3 rounded-circle" src="http://placehold.it/50x50" alt="">
{% for _c in c.comments %}
<div class="media mt-4 comment-container" id="comment-{{_c.id}}">
<div class="votearrow" title="upvote"></div>
<div class="media-body">
<h5 class="mt-0">Commenter Name</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc
ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
<span class="username">
<a class="{% if c.user.username == proposal.user.username %}author{% endif %}" href="/user/{{ c.user.username }}">
{{_c.user.username}}
</a>
</span>
<span class="date_posted">
<a href="/proposal/{{proposal.id}}#comment-{{_c.id}}">
{{c.date_added.strftime('%Y-%m-%d %H:%M')}}
</a>
</span><br>
{{_c.message}}
</div>
</div>
<div class="media mt-4">
<img class="d-flex mr-3 rounded-circle" src="http://placehold.it/50x50" alt="">
<div class="media-body">
<h5 class="mt-0">Commenter Name</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc
ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>

View file

@ -1,17 +1,15 @@
{% with messages = get_flashed_messages() %}
{% with messages = get_flashed_messages(with_categories=True) %}
{% if messages %}
<div class="row">
<div class="col-lg-12">
{% for message in messages %}
{% if message.category != 'error' %}
<div class="alert alert-success">
{{ message }}
</div>
{% else %}
<div class="alert alert-danger">
{{ message }}
</div>
{% endif %}
<div class="alert {% if message[0] != 'error' %}alert-success{% else %}alert-danger{% endif %}">
<img src="/static/doge_head.png" style="
width: 64px;
margin-right: 8px;
">
{{ message[1] }}
</div>
{% endfor %}
</div>
</div>