aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2012-11-09 23:44:09 +0100
committerThibaut Horel <thibaut.horel@gmail.com>2012-11-09 23:44:09 +0100
commit2cf883a2512c5b5248d6bce5b7baed72abc1b99d (patch)
tree7da473422772364e66114a15068b5fd6f17e237c
parent76d58425de6a1e3505c777921b1e58bf03370366 (diff)
downloadfamille-flask-2cf883a2512c5b5248d6bce5b7baed72abc1b99d.tar.gz
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
-rw-r--r--famille.py7
1 files changed, 5 insertions, 2 deletions
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/<int:user_id>/')
@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'])