aboutsummaryrefslogtreecommitdiffstats
path: root/famille.py
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2015-04-02 15:59:31 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2015-04-02 16:27:26 -0400
commite538ee5f4e62cc9d85a9e3a94bcbb1e3406c955e (patch)
treef1bea4e089eb4eda58562274447374a00767b2f3 /famille.py
parentd390b55e60bf97de9010ff518943920b680657b0 (diff)
downloadfamille-flask-e538ee5f4e62cc9d85a9e3a94bcbb1e3406c955e.tar.gz
move to python3
Diffstat (limited to 'famille.py')
-rw-r--r--famille.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/famille.py b/famille.py
index 0a4a3d6..634090c 100644
--- a/famille.py
+++ b/famille.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import sqlite3
#all the imports
from flask import Flask, request, session, g, redirect,\
@@ -43,25 +42,22 @@ def shortify(string):
@app.template_filter('format_date')
-def format_date(date_object, format=u"%a %d %b %Y à %Hh%M"):
+def format_date(date_object, format="%a %d %b %Y à %Hh%M"):
if not date_object:
return ""
- format = format.encode("utf8")
return date_object.replace(tzinfo=timezone('utc')).\
- astimezone(timezone(session['timezone'])).\
- strftime(format).decode("utf8")
+ astimezone(timezone(session['timezone'])).strftime(format)
@app.template_filter('format_ago')
def format_ago(date_object, format):
if not date_object:
return ""
- format = format.encode("utf8")
readable = date_object.replace(tzinfo=timezone('utc')).\
astimezone(timezone(session['timezone'])).strftime(format)
iso_format = date_object.strftime('%Y-%m-%dT%H:%M:%SZ')
return '<span class=timeago title="{0}">{1}</span>'.\
- format(iso_format, readable).decode("utf8")
+ format(iso_format, readable)
@app.template_filter('format_rfc2822')
@@ -268,7 +264,7 @@ def edit_user():
result['password'] = hashlib.md5(request.form['password']).\
hexdigest()
else:
- error = u"Les deux mots de passe ne coïncident pas"
+ error = "Les deux mots de passe ne coïncident pas"
return render_template("user/edit.html", user=request.form,
error=error)
except KeyError:
@@ -294,7 +290,7 @@ def login():
if request.method == 'POST':
username = request.form['username']
- password = hashlib.md5(request.form['password']).hexdigest()
+ password = hashlib.md5(request.form['password'].encode("utf-8")).hexdigest()
user = query_db('select * from users where user_name = ?',
(username,), True)
if user:
@@ -308,10 +304,10 @@ def login():
db.commit()
return redirect(url_for('list_news'))
else:
- flash(u'Mot de passe incorrect')
+ flash('Mot de passe incorrect')
return redirect(url_for('login'))
else:
- flash(u'Utilisateur non enregistré')
+ flash('Utilisateur non enregistré')
return redirect(url_for('login'))
return render_template('login.html')