From 2cf883a2512c5b5248d6bce5b7baed72abc1b99d Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Fri, 9 Nov 2012 23:44:09 +0100 Subject: Fix two bugs * make the shortening function backward compatible to old comments * fix a bug where the show_user function would always display the current user's profile --- famille.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'famille.py') diff --git a/famille.py b/famille.py index 0d2e7b9..f289508 100644 --- a/famille.py +++ b/famille.py @@ -22,7 +22,10 @@ app.config.from_envvar('CONF') @app.template_filter('shortify') def shortify(string): soup = BeautifulSoup(string) - return soup("p")[0].get_text()[:50] + try: + return soup("p")[0].get_text()[:50] + except IndexError: + return string @app.template_filter('format_date') def format_date(datetime_string, format=u"%a %d %b %Y à %Hh%M".encode("utf8")): @@ -139,7 +142,7 @@ def edit_news(news_id): @app.route('/user//') @login_required def view_user(user_id): - user = query_db('SELECT * FROM users WHERE id= ?', (session['user_id'],), True) + user = query_db('SELECT * FROM users WHERE id= ?', (user_id,), True) return render_template("user/show.html", user=user) @app.route('/user/edit/', methods=['GET', 'POST']) -- cgit v1.2.3-70-g09d2