Update templates/post.html

main
Elīna Lukjanoviča 2024-04-29 09:26:15 +00:00
parent 831545696e
commit 55552e14b7
1 changed files with 38 additions and 26 deletions

View File

@ -20,33 +20,45 @@
<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>
<div> <div>
{% if post.comments %} <h3 class="mt-4">{{ comment_count }} Comments</h3>
<h3 class="mt-4">{{ post.comments.count() }} Comments</h3>
{% else %}
<h3>0 Comments</h4>
{% endif %}
</div> </div>
</div>
{% if comments %} {% if comments %}
<div class="mt-4">
<ul class="list-group"> <ul class="list-group">
{% for comment in comments %} {% for comment in comments %}
<li class="list-group-item"> <li class="list-group-item">
<strong>{{ comment.created_by }}</strong>: {{ comment.text }} <div class="d-flex justify-content-between align-items-center">
<strong>{{ comment.created_by }}</strong>
<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> </li>
{% endfor %} {% endfor %}
</ul> </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 %}
<div class="mt-4">
<h3>Add a Comment</h3>
<form method="POST"> <form method="POST">
<div> <input type="hidden" name="created_by" value="{{ g.user.username }}">
<textarea class="form-control" id="comment" name="comment" rows="3"></textarea> <div class="form-group">
<textarea class="form-control" id="comment" name="text" rows="3"></textarea>
</div> </div>
<button type="submit" class="btn btn-primary mt-3">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
</form> </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 %}