Update templates/post.html
							parent
							
								
									831545696e
								
							
						
					
					
						commit
						55552e14b7
					
				| 
						 | 
				
			
			@ -14,39 +14,51 @@
 | 
			
		|||
        {% endfor %}
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="d-flex justify-content-between align-items-center mt-4">
 | 
			
		||||
        <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('downvote_post', post_id=post.id) }}" class="btn btn-sm btn-danger"><i class="fas fa-arrow-down"></i> Downvote ({{ post.downvotes }})</a>
 | 
			
		||||
        <div class="d-flex justify-content-between align-items-center mt-4">
 | 
			
		||||
            <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('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>
 | 
			
		||||
    {% if post.comments %}
 | 
			
		||||
    <h3 class="mt-4">{{ post.comments.count() }} Comments</h3>
 | 
			
		||||
    {% else %}
 | 
			
		||||
    <h3>0 Comments</h4>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    {% if comments %}
 | 
			
		||||
    <ul class="list-group">
 | 
			
		||||
        {% for comment in comments %}
 | 
			
		||||
        <li class="list-group-item">
 | 
			
		||||
            <strong>{{ comment.created_by }}</strong>: {{ comment.text }}
 | 
			
		||||
        </li>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
    </ul>
 | 
			
		||||
    <div class="mt-4">
 | 
			
		||||
        <ul class="list-group">
 | 
			
		||||
            {% for comment in comments %}
 | 
			
		||||
            <li class="list-group-item">
 | 
			
		||||
                <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>
 | 
			
		||||
            {% endfor %}
 | 
			
		||||
        </ul>
 | 
			
		||||
    </div>
 | 
			
		||||
    {% 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 %}
 | 
			
		||||
 | 
			
		||||
    {% if g.user %}
 | 
			
		||||
    <form method="POST">
 | 
			
		||||
        <div>
 | 
			
		||||
            <textarea class="form-control" id="comment" name="comment" rows="3"></textarea>
 | 
			
		||||
        </div>
 | 
			
		||||
        <button type="submit" class="btn btn-primary mt-3">Submit</button>
 | 
			
		||||
    </form>
 | 
			
		||||
    <div class="mt-4">
 | 
			
		||||
        <h3>Add a Comment</h3>
 | 
			
		||||
        <form method="POST">
 | 
			
		||||
            <input type="hidden" name="created_by" value="{{ g.user.username }}">
 | 
			
		||||
            <div class="form-group">
 | 
			
		||||
                <textarea class="form-control" id="comment" name="text" rows="3"></textarea>
 | 
			
		||||
            </div>
 | 
			
		||||
            <button type="submit" class="btn btn-primary">Submit</button>
 | 
			
		||||
        </form>
 | 
			
		||||
    </div>
 | 
			
		||||
    {% else %}
 | 
			
		||||
    <p>Log in to leave a comment.</p>
 | 
			
		||||
    <p class="mt-4">Log in to leave a comment.</p>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
</div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue