Working code, failing test
This commit is contained in:
parent
39243beff4
commit
f2fb55ea33
6 changed files with 89 additions and 2 deletions
|
|
@ -28,6 +28,23 @@ def index():
|
|||
posts.append(post)
|
||||
return render_template('blog/index.html', posts=posts)
|
||||
|
||||
@bp.route('/firehose')
|
||||
def firehose():
|
||||
db = get_db()
|
||||
db_posts = db.execute(
|
||||
'SELECT p.id, title, body, created, author_id, username'
|
||||
' FROM post p JOIN user u ON p.author_id = u.id'
|
||||
' ORDER BY created DESC'
|
||||
).fetchall()
|
||||
posts = []
|
||||
for post in db_posts:
|
||||
if post['created'] > datetime.datetime.utcnow():
|
||||
continue
|
||||
post = dict(post)
|
||||
post['body'] = markdown.markdown(post['body'])
|
||||
posts.append(post)
|
||||
return render_template('blog/firehose.html', posts=posts)
|
||||
|
||||
@bp.route('/create',methods=('GET', 'POST'))
|
||||
@login_required
|
||||
def create():
|
||||
|
|
@ -69,6 +86,11 @@ def get_post(id, check_author=True):
|
|||
|
||||
return post
|
||||
|
||||
@bp.route('/<int:id>')
|
||||
def individual_post(id):
|
||||
post = get_post(id, False)
|
||||
return render_template('blog/post.html', post=post)
|
||||
|
||||
@bp.route('/<int:id>/update', methods=('GET', 'POST'))
|
||||
@login_required
|
||||
def update(id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue