Current prod version
This commit is contained in:
parent
f52d98333e
commit
34c5300608
7 changed files with 32 additions and 11 deletions
|
|
@ -7,6 +7,7 @@ from flaskr.auth import login_required
|
|||
from flaskr.db import get_db
|
||||
|
||||
import markdown
|
||||
import datetime
|
||||
|
||||
bp = Blueprint('blog', __name__)
|
||||
|
||||
|
|
@ -20,6 +21,8 @@ def index():
|
|||
).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)
|
||||
|
|
@ -74,19 +77,23 @@ def update(id):
|
|||
if request.method == 'POST':
|
||||
title = request.form['title']
|
||||
body = request.form['body']
|
||||
created = request.form['created']
|
||||
error = None
|
||||
|
||||
if not title:
|
||||
error = 'Title is required.'
|
||||
|
||||
if not created:
|
||||
error = "Created is required."
|
||||
|
||||
if error is not None:
|
||||
flash(error)
|
||||
else:
|
||||
db = get_db()
|
||||
db.execute(
|
||||
'UPDATE post SET title = ?, body = ?'
|
||||
'UPDATE post SET title = ?, body = ?, created = ?'
|
||||
' WHERE id = ?',
|
||||
(title, body, id)
|
||||
(title, body, created, id)
|
||||
)
|
||||
db.commit()
|
||||
return redirect(url_for('blog.index'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue