From 1ab9d17135c87253d9e1531cc31cf1b4ac94eceb Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Thu, 8 Nov 2012 00:15:24 +0100 Subject: Also use rst for news content --- famille.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'famille.py') diff --git a/famille.py b/famille.py index 6b128d6..87a1118 100644 --- a/famille.py +++ b/famille.py @@ -8,7 +8,7 @@ import hashlib from docutils import core from docutils.writers.html4css1 import Writer -def rstify_comment(string): +def rstify(string): w = Writer() result = core.publish_parts(string, writer=w)['fragment'] return result @@ -53,9 +53,10 @@ def list_news(): @login_required def add_news(): if request.method == 'POST': + content = rstify(request.form['content']) cur = g.db.execute("INSERT INTO news ('title', 'content', 'user_id') " "VALUES (?, ?, ?)", - (request.form['title'], request.form['content'], + (request.form['title'], content, session['user_id'])) news_id = cur.lastrowid g.db.commit() @@ -80,7 +81,7 @@ def show_news(news_id): "VALUES (?, ?, ?)", (user_id, content, news_id)) g.db.commit() return redirect(url_for('show_news', news_id=news_id)) - + @app.route('/login/', methods=['GET', 'POST']) def login(): if 'user_name' in session: -- cgit v1.2.3-70-g09d2