diff options
| -rw-r--r-- | famille.py | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -193,13 +193,14 @@ def show_news(news_id): elif request.method == 'POST': user_id = session['user_id'] content = request.form['content'] - content_cache = rstify(content) - db = get_db() - db.execute("INSERT INTO comments " - "('user_id', 'content', 'news_id', 'content_cache') " - "VALUES (?, ?, ?, ?)", - (user_id, content, news_id, content_cache)) - db.commit() + if content: + content_cache = rstify(content) + db = get_db() + db.execute("INSERT INTO comments " + "('user_id', 'content', 'news_id', 'content_cache') " + "VALUES (?, ?, ?, ?)", + (user_id, content, news_id, content_cache)) + db.commit() return redirect(url_for('show_news', news_id=news_id)) |
