X-Git-Url: http://git.cyclocoop.org/%22.%24redirect_annul.%22?a=blobdiff_plain;f=reminder.py;h=90eebf4e7ac40b414f6430b621d51c4211028ed7;hb=8c826b6a4c1ea070424027c1a99ad0f6b5eebd19;hp=67335a6d4065fcbb9da46f567875639a49e4fdf4;hpb=cf3f4e59946cf26baefabce08e3f41a35c60e7db;p=cavote.git diff --git a/reminder.py b/reminder.py index 67335a6..90eebf4 100644 --- a/reminder.py +++ b/reminder.py @@ -6,7 +6,7 @@ from datetime import date, datetime, timedelta import time from settings import * - +from flaskext.babel import gettext import sqlite3 @@ -40,43 +40,48 @@ for vote in c.execute('select id, id_group, date_end, title from votes where is_ BODY = string.join(( "From: %s" % EMAIL, "To: %s" % user[1], - "Subject: [Cavote] Vote reminder - You didn't take part to it", + "Subject: [Cavote] %s" % gettext(u"Vote reminder - You didn't take part to it"), "Date: %s" % time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()).decode('utf-8'), + "Content-type: text/plain; charset=utf-8", "X-Mailer: %s" % VERSION, "", - "A vote concerns you and is going to terminate on %s : %s" % (vote[2], vote[3]), - "You still didn't take part to it !", + "%s %s : %s" % (gettext(u"A vote concerns you and is going + to terminate on"), vote[2], vote[3].encode('utf-8')), + gettext(u"You still didn't take part to it !"), "", - "This link will bring you to the form where you will be able to participate :", + gettext(u"This link will bring you to the form where you will be able to participate :"), link, "", - "If you think this mail is not for you, please ignore and delete it." + gettext(u"If you think this mail is not for you, please ignore and delete it.") ), "\r\n") server = smtplib.SMTP(SMTP_SERVER) print EMAIL print user[1] print BODY - server.sendmail(EMAIL, user[1], BODY) + server.sendmail(EMAIL, user[1], BODY.encode('utf-8')) server.quit() else: BODY = string.join(( "From: %s" % EMAIL, "To: %s" % user[1], - "Subject: [Cavote] Vote reminder - Last days to modify your choice", + "Subject: [Cavote] %s" % gettext(u"Vote reminder - Last days to modify your choice"), "Date: %s" % time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()).decode('utf-8'), + "Content-type: text/plain; charset=utf-8", "X-Mailer: %s" % VERSION, "", - "A vote concerns you and is going to terminate on %s : %s" % (vote[2], vote[3]), - "You have already voted by can still modify you choice", + "%s %s : %s" % (gettext(u"A vote concerns you and is going + to terminate on "), vote[2], vote[3].encode('utf-8')), + gettext(u"You have already voted but you can still modify + your choice"), "", - "This link will bring you to the form where you will be able to participate :", + gettext(u"This link will bring you to the form where you will be able to participate :"), link, "", - "If you think this mail is not for you, please ignore and delete it." + gettext(u"If you think this mail is not for you, please ignore and delete it.") ), "\r\n") server = smtplib.SMTP(SMTP_SERVER) print EMAIL print user[1] print BODY - server.sendmail(EMAIL, user[1], BODY) + server.sendmail(EMAIL, user[1], BODY.encode('utf-8')) server.quit()