From 76804575ffcf6c8779512eb8cfae8b879eb80d0e Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 9 Dec 2013 17:16:42 +0100 Subject: [PATCH] fix reminder, fix bad user destination in message --- teleforma/locale/fr/LC_MESSAGES/django.mo | Bin 20553 -> 19325 bytes teleforma/locale/fr/LC_MESSAGES/django.po | 34 +++++---- .../teleforma-message-all-seminar-users.py | 66 ++++++++---------- teleforma/templates/postman/base_write.html | 2 + .../teleforma/messages/seminar_remind.txt | 10 ++- 5 files changed, 60 insertions(+), 52 deletions(-) diff --git a/teleforma/locale/fr/LC_MESSAGES/django.mo b/teleforma/locale/fr/LC_MESSAGES/django.mo index fd978ced30fcef526f2fdf52ba21e99e7b82e671..20590c425ee35d22d844e0bb23cb8f96ced0ae66 100644 GIT binary patch delta 6092 zcmY+|349KB9>?*2|hP$cfCBUVTe)Ujn-QMTe}8+EixsH>f#b+lNd&Zf&Q zYEeBz*`%#&tz&K7RVhVQY@KOYsk6uD`^?YlW#{$!=KY`l%>1vJXP$@sD}#Po9ORve z30dUWDg`-L4Ud;}ZXD$~fkffc{@=nvB&n0q53n@0nur=$Dr#T@P#veEo{bFK_eN7t$Kz2APDORF5H*0+sD?j5HI#>1 zk?nT;AgbY0sD{s@27C#1{tu}0i&5u=#Mv!ER?>47ts)+^L@oUTt|MvyPh)c&it1o7 zYCzej8LmMMI2Uzm4xnzqIaG&57=k~duDgd?`jEQL#nQivrl5u!qXv+Ox}XDA#LiYf z5Y=G@2ICa$hp%H_Jc)XPCe-uqc{gm&eiqipqnLpAunE?Gls4$!rBT>`Utv5>DQWc6GzhGLZl{u0L`Z&_CldF#3kSQ67v10Rfm_l7wgHL-bS7JBMnDFt1)5_Q2k z)Jkkd&3Fgu!s8f*`F8vq>iVnZP1N=GQMVwxp?~iym~p7%El};ZZ^-&rpwOKPU65`E zMw^pR9nL__bS`S3Yt4^Q_dFLhz=P&7)O9Cq|14_d3Q@Q2vh5c&Wc_vECKVddT~r5Q z+=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$MlaKUK~qCllj(`W}eHV zRMruF6QH{GxQF~| z^@VthTxoUDi7XDgmzd%99H1cq$#7}G-O8#Q?Dm+B= z9tfx7cW@2SQ9{nAtqhaNUeb>IiRieHoFIkdMe+^#o@^pFYX94D^JLWV3b{K};=hQ@ z=Wq_$Z1uC~9kG)vAXkx_h>izHJc%P&WDuE2!WidOtR<}|>o-8~&-~MdJWe{3vqyU_ zID1r6_=wy~8b}o9KEdxuOS>+LvW^a940(p=@5Wn1$LA!%u6=}ZEV)C^|9T3G$t3c3 za`rf2h3WY2*+%@DB$BJiEo2-SPCg?AL`S2G^Dq3HmBq7UH(9Sr=wSaNnbp%&`V&97 zm0Ux%ktEJFqmHg55GwKCh`5AYP9~6g63?~isG}EIMlMi=<87DFucKjD*RPGk9TH8dAV<{uiWqP)+O{#&g`D18sH)UoU3YVz#37#aqKdhdeqUCVue>;5r#wEtr^;6p@RgROS7&&N z8M&e;ptV$cihFpA`~h!SslRDUMy98{?!}y>0Y$z*ZB|h!6JfbrR@$_=%3V8Gl`&q4 zw`#V}JJX#Mlk>6y7LzrrqH1p4i9sC`=LD+f1$uY`|J{SGbzvzB8?NuPzHRg+p4^=N zeexSpvTuv1D;V6lt~u|{hH<^i!c=K!&hvy@Yp4Hj{{L$8b8_c}b~m-})b{@YZQfbk diff --git a/teleforma/locale/fr/LC_MESSAGES/django.po b/teleforma/locale/fr/LC_MESSAGES/django.po index 42029044..54a9c52c 100644 --- a/teleforma/locale/fr/LC_MESSAGES/django.po +++ b/teleforma/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-12-06 21:58+0100\n" +"POT-Creation-Date: 2013-12-09 16:45+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Guillaume Pellerin \n" "Language-Team: LANGUAGE \n" @@ -1407,7 +1407,7 @@ msgstr "" "de votre formation avant le %(date)s.\n" "\n" "L’équipe e-learning de %(organization)s vous remercie de votre confiance et " -"reste à votre disposition pour renseignement complémentaire.\n" +"reste à votre disposition pour tout renseignement complémentaire.\n" #: templates/teleforma/messages/answer_validated.txt:1 #, python-format @@ -1441,32 +1441,39 @@ msgstr "" "de votre formation avant le %(date)s.\n" "\n" "L’équipe e-learning de %(organization)s vous remercie de votre confiance et " -"reste à votre disposition pour renseignement complémentaire.\n" +"reste à votre disposition pour tout renseignement complémentaire.\n" #: templates/teleforma/messages/seminar_remind.txt:1 #, python-format msgid "" "%(gender)s %(last_name)s,\n" "\n" -"votre abonnement au séminaire e-learning \"%(title)s\" arrive à expiration " -"le %(date)s.\n" +"Certains de vos séminaires e-learning arrivent bientôt à expiration :" +msgstr "" +"%(gender)s %(last_name)s,\n" "\n" -"Nous vous rappelons que vous devez achever votre formation avant cette " -"date.\n" +"Certains de vos séminaires e-learning arrivent bientôt à expiration :" + +#: templates/teleforma/messages/seminar_remind.txt:6 +msgid "expires on" +msgstr "arrive à expiration le" + +#: templates/teleforma/messages/seminar_remind.txt:8 +msgid "" +"\n" +"Nous vous rappelons que vous devez achever vos formations avant ces dates.\n" "\n" "De plus, si vous souhaitez conserver les supports pédagogiques écrits de " "votre formation (compte-rendu écrit et recueil(s) de documents d'actualité), " "nous vous rappelons que ceux-ci sont entièrement téléchargeables sur la " -"plate-forme e-learning de Pro-Barreau jusqu'au %(date)s.\"\n" +"plate-forme e-learning de %(organization)s jusqu'aux dates d'expiration de " +"chaque séminaire.\"\n" "\n" "The team of the %(organization)s thank you for your confidence and we remain " "at your disposal for further information.\n" msgstr "" "%(gender)s %(last_name)s,\n" "\n" -"votre abonnement au séminaire e-learning \"%(title)s\" arrive à expiration " -"le %(date)s.\n" -"\n" "Nous vous rappelons que vous devez achever votre formation avant cette " "date.\n" "\n" @@ -1476,7 +1483,7 @@ msgstr "" "plate-forme e-learning de Pro-Barreau jusqu'au %(date)s.\"\n" "\n" "L’équipe e-learning de %(organization)s vous remercie de votre confiance et " -"reste à votre disposition pour renseignement complémentaire.\n" +"reste à votre disposition pour tout renseignement complémentaire.\n" #: templates/teleforma/messages/seminar_validated.txt:1 #, python-format @@ -1515,7 +1522,7 @@ msgstr "" "de votre formation avant le %(date)s.\n" "\n" "L’équipe e-learning de %(organization)s vous remercie de votre confiance et " -"reste à votre disposition pour renseignement complémentaire.\n" +"reste à votre disposition pour tout renseignement complémentaire.\n" #: templates/telemeta/base.html:97 msgid "Desk" @@ -1679,7 +1686,6 @@ msgid "Email" msgstr "" #: templates/telemeta/profile_detail.html:85 -#, fuzzy msgid "Expiration date" msgstr "Date d'expiration" diff --git a/teleforma/management/commands/teleforma-message-all-seminar-users.py b/teleforma/management/commands/teleforma-message-all-seminar-users.py index c26a6e00..b631e33e 100644 --- a/teleforma/management/commands/teleforma-message-all-seminar-users.py +++ b/teleforma/management/commands/teleforma-message-all-seminar-users.py @@ -17,14 +17,16 @@ from postman.models import * from postman.utils import email_visitor, notify_user - class Command(BaseCommand): - help = "Broadcast a message to all users thanks to their subscription" + help = """Send a reminder to all users when their subscripted seminars + expire before a given number of days""" + args ['days'] message_template = 'teleforma/messages/seminar_remind.txt' subject_template = 'teleforma/messages/seminar_remind_subject.txt' language_code = 'fr_FR' - def handle(self, *args, **options): + def handle(self, *args, **kwargs): + days = args[-1] users = User.objects.all() translation.activate(self.language_code) sender_email = settings.DEFAULT_FROM_EMAIL @@ -34,43 +36,37 @@ class Command(BaseCommand): for user in users: auditor = user.auditor.all() professor = user.professor.all() + seminars = [] if auditor and not professor and user.is_active and user.email: auditor = auditor[0] - seminars = auditor.seminars.all() - for seminar in seminars: + context = {} + all_seminars = auditor.seminars.all() + + for seminar in all_seminars: if seminar.expiry_date: delta = seminar.expiry_date - today - if delta.days < 30: - context = {} - organization = seminar.course.department.name - site = Site.objects.get_current() - path = reverse('teleforma-seminar-detail', kwargs={'pk':seminar.id}) - gender = auditor.get_gender_display() - - if seminar.sub_title: - title = seminar.sub_title + ' : ' + seminar.title - else: - title = seminar.title + if delta.days < days: + seminars.append(seminar) - context['gender'] = gender - context['first_name'] = user.first_name - context['last_name'] = user.last_name - context['site'] = site - context['path'] = path - context['title'] = title - context['organization'] = organization - context['date'] = seminar.expiry_date - - text = render_to_string(self.message_template, context) - subject = render_to_string(self.subject_template, context) - subject = '%s : %s' % (seminar.title, subject) + if seminars: + context['organization'] = seminars[0].course.department.name + context['gender'] = auditor.get_gender_display() + context['first_name'] = user.first_name + context['last_name'] = user.last_name + context['site'] = Site.objects.get_current() + context['seminars'] = seminars + + text = render_to_string(self.message_template, context) + subject = render_to_string(self.subject_template, context) + subject = '%s : %s' % (seminar.title, subject) - mess = Message(sender=sender, recipient=user, subject=subject[:119], body=text) - mess.moderation_status = 'a' - mess.save() - if not settings.DEBUG: - notify_user(mess, 'acceptance') - - print user.username, seminar.title, seminar.expiry_date + mess = Message(sender=sender, recipient=user, subject=subject[:119], body=text) + mess.moderation_status = 'a' + mess.save() + + if not settings.DEBUG: + notify_user(mess, 'acceptance') + + print user.username, seminars diff --git a/teleforma/templates/postman/base_write.html b/teleforma/templates/postman/base_write.html index f4d7bfaf..40c4f22f 100644 --- a/teleforma/templates/postman/base_write.html +++ b/teleforma/templates/postman/base_write.html @@ -19,10 +19,12 @@