aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2012-11-10 16:29:18 +0100
committerThibaut Horel <thibaut.horel@gmail.com>2012-11-10 16:29:18 +0100
commit0ae7f695448d5384f9fc6037e7acc7177fd55f55 (patch)
tree2fb42301ef0df503d4c48632025a522d5243a0bb
parent305aa87825be13ba329fda96bd175b3dff0914bb (diff)
downloadfamille-flask-0ae7f695448d5384f9fc6037e7acc7177fd55f55.tar.gz
Fix locales and minor encoding issue
-rw-r--r--famille.py7
-rw-r--r--templates/news/list.html2
2 files changed, 6 insertions, 3 deletions
diff --git a/famille.py b/famille.py
index 7ac36a7..203bc23 100644
--- a/famille.py
+++ b/famille.py
@@ -10,6 +10,8 @@ from docutils.writers.html4css1 import Writer
from datetime import datetime
from bs4 import BeautifulSoup
from flask_mail import Mail, Message
+import locale
+locale.setlocale(locale.LC_ALL, 'fr_FR')
def rstify(string):
w = Writer()
@@ -30,9 +32,10 @@ def shortify(string):
return string
@app.template_filter('format_date')
-def format_date(date_object, format=u"%a %d %b %Y à %Hh%M".encode("utf8")):
+def format_date(date_object, format=u"%a %d %b %Y à %Hh%M"):
if not date_object:
return ""
+ format = format.encode("utf8")
return date_object.strftime(format).decode("utf8")
@app.template_filter('pluralize')
@@ -97,7 +100,7 @@ def add_news():
emails = query_db("SELECT email from users where notify=1")
emails = [email["email"] for email in emails]
message = Message(request.form['title'], sender="news.horel@gmail.com")
- message.html = content_cache
+ message.body = content_cache
message.recipients = emails
mail.send(message)
diff --git a/templates/news/list.html b/templates/news/list.html
index 2f273e1..99d1571 100644
--- a/templates/news/list.html
+++ b/templates/news/list.html
@@ -11,7 +11,7 @@
{% for user in users %}
<tr>
<td><a href="{{url_for('view_user', user_id=user.id)}}">{{user.user_name}}</a></td>
- <td>{{user.last_seen|format_date}}</td>
+ <td>{{user.last_seen|format_date('%a %d %b à %Hh%M')}}</td>
</tr>
{% endfor %}
</table>