Update templates/post.html
parent
831545696e
commit
55552e14b7
|
@ -14,39 +14,51 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex justify-content-between align-items-center mt-4">
|
<div class="d-flex justify-content-between align-items-center mt-4">
|
||||||
<div>
|
<div>
|
||||||
<a href="{{ url_for('upvote_post', post_id=post.id) }}" class="btn btn-sm btn-success"><i class="fas fa-arrow-up"></i> Upvote ({{ post.upvotes }})</a>
|
<a href="{{ url_for('upvote_post', post_id=post.id) }}" class="btn btn-sm btn-success"><i class="fas fa-arrow-up"></i> Upvote ({{ post.upvotes }})</a>
|
||||||
<a href="{{ url_for('downvote_post', post_id=post.id) }}" class="btn btn-sm btn-danger"><i class="fas fa-arrow-down"></i> Downvote ({{ post.downvotes }})</a>
|
<a href="{{ url_for('downvote_post', post_id=post.id) }}" class="btn btn-sm btn-danger"><i class="fas fa-arrow-down"></i> Downvote ({{ post.downvotes }})</a>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="mt-4">{{ comment_count }} Comments</h3>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
{% if post.comments %}
|
|
||||||
<h3 class="mt-4">{{ post.comments.count() }} Comments</h3>
|
|
||||||
{% else %}
|
|
||||||
<h3>0 Comments</h4>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% if comments %}
|
{% if comments %}
|
||||||
<ul class="list-group">
|
<div class="mt-4">
|
||||||
{% for comment in comments %}
|
<ul class="list-group">
|
||||||
<li class="list-group-item">
|
{% for comment in comments %}
|
||||||
<strong>{{ comment.created_by }}</strong>: {{ comment.text }}
|
<li class="list-group-item">
|
||||||
</li>
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
{% endfor %}
|
<strong>{{ comment.created_by }}</strong>
|
||||||
</ul>
|
<span>{{ comment.creation_date.strftime('%Y-%m-%d %H:%M') }}</span>
|
||||||
|
</div>
|
||||||
|
<p>{{ comment.text }}</p>
|
||||||
|
<div>
|
||||||
|
<a href="{{ url_for('upvote_comment', comment_id=comment.id) }}" class="btn btn-sm btn-success"><i class="fas fa-arrow-up"></i> Upvote ({{ comment.upvotes }})</a>
|
||||||
|
<a href="{{ url_for('downvote_comment', comment_id=comment.id) }}" class="btn btn-sm btn-danger"><i class="fas fa-arrow-down"></i> Downvote ({{ comment.downvotes }})</a></br></br>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No comments yet. Be the first to comment!</p>
|
<p class="mt-4">No comments yet. Be the first to comment!</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if g.user %}
|
{% if g.user %}
|
||||||
<form method="POST">
|
<div class="mt-4">
|
||||||
<div>
|
<h3>Add a Comment</h3>
|
||||||
<textarea class="form-control" id="comment" name="comment" rows="3"></textarea>
|
<form method="POST">
|
||||||
</div>
|
<input type="hidden" name="created_by" value="{{ g.user.username }}">
|
||||||
<button type="submit" class="btn btn-primary mt-3">Submit</button>
|
<div class="form-group">
|
||||||
</form>
|
<textarea class="form-control" id="comment" name="text" rows="3"></textarea>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Log in to leave a comment.</p>
|
<p class="mt-4">Log in to leave a comment.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue