forked from miguelgrinberg/flasky
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chapter 13: Blog post comments (13a)
- Loading branch information
1 parent
b4b18ad
commit aa10857
Showing
12 changed files
with
168 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<ul class="comments"> | ||
{% for comment in comments %} | ||
<li class="comment"> | ||
<div class="comment-thumbnail"> | ||
<a href="{{ url_for('.user', username=comment.author.username) }}"> | ||
<img class="img-rounded profile-thumbnail" src="{{ comment.author.gravatar(size=40) }}"> | ||
</a> | ||
</div> | ||
<div class="comment-content"> | ||
<div class="comment-date">{{ moment(comment.timestamp).fromNow() }}</div> | ||
<div class="comment-author"><a href="{{ url_for('.user', username=comment.author.username) }}">{{ comment.author.username }}</a></div> | ||
<div class="comment-body"> | ||
{% if comment.body_html %} | ||
{{ comment.body_html | safe }} | ||
{% else %} | ||
{{ comment.body }} | ||
{% endif %} | ||
</div> | ||
</div> | ||
</li> | ||
{% endfor %} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
{% extends "base.html" %} | ||
{% import "bootstrap/wtf.html" as wtf %} | ||
{% import "_macros.html" as macros %} | ||
|
||
{% block title %}Flasky - Post{% endblock %} | ||
|
||
{% block page_content %} | ||
{% include '_posts.html' %} | ||
<h4 id="comments">Comments</h4> | ||
{% if current_user.can(Permission.COMMENT) %} | ||
<div class="comment-form"> | ||
{{ wtf.quick_form(form) }} | ||
</div> | ||
{% endif %} | ||
{% include '_comments.html' %} | ||
{% if pagination %} | ||
<div class="pagination"> | ||
{{ macros.pagination_widget(pagination, '.post', fragment='#comments', id=posts[0].id) }} | ||
</div> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""comments | ||
Revision ID: 51f5ccfba190 | ||
Revises: 2356a38169ea | ||
Create Date: 2014-01-01 12:08:43.287523 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '51f5ccfba190' | ||
down_revision = '2356a38169ea' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('comments', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('body', sa.Text(), nullable=True), | ||
sa.Column('body_html', sa.Text(), nullable=True), | ||
sa.Column('timestamp', sa.DateTime(), nullable=True), | ||
sa.Column('disabled', sa.Boolean(), nullable=True), | ||
sa.Column('author_id', sa.Integer(), nullable=True), | ||
sa.Column('post_id', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), | ||
sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_index('ix_comments_timestamp', 'comments', ['timestamp'], unique=False) | ||
### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index('ix_comments_timestamp', 'comments') | ||
op.drop_table('comments') | ||
### end Alembic commands ### |