Update templates/post.html
parent
5d3153ecfd
commit
4cac6be5bb
|
@ -2,35 +2,30 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h2>Create New Post</h2>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="form-group">
|
||||
{{ form.category_id.label }}<br>
|
||||
{{ form.category_id(class="form-control") }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.post_name.label }}<br>
|
||||
{{ form.post_name(class="form-control") }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.created_by.label }}<br>
|
||||
{{ form.created_by(class="form-control") }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.text.label }}<br>
|
||||
{{ form.text(class="form-control") }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.media.label }}<br>
|
||||
{{ form.media(class="form-control-file") }}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Create Post</button>
|
||||
</form>
|
||||
|
||||
<h2>{{ post.post_name }}</h2>
|
||||
<p>Created by {{ post.created_by }} - {{ post.creation_date.strftime('%Y-%m-%d %H:%M') }}</p>
|
||||
<hr>
|
||||
<div>
|
||||
<p>{{ post.text }}</p>
|
||||
{% for media in post.media %}
|
||||
<div class="mt-4">
|
||||
<img src="/uploads/{{ media.filename }}" alt="Media" class="img-fluid">
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<h3>Comments</h3>
|
||||
<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>
|
||||
{% 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 %}
|
||||
|
@ -45,11 +40,10 @@
|
|||
|
||||
{% if g.user %}
|
||||
<form method="POST">
|
||||
<div class="form-group">
|
||||
<label for="comment">Leave a comment:</label>
|
||||
<div>
|
||||
<textarea class="form-control" id="comment" name="comment" rows="3"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="submit" class="btn btn-primary mt-3">Submit</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p>Log in to leave a comment.</p>
|
||||
|
|
Loading…
Reference in New Issue