From: Guillaume Pellerin Date: Mon, 9 Dec 2013 16:16:42 +0000 (+0100) Subject: fix reminder, fix bad user destination in message X-Git-Tag: 2.8.1-pro~469^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=76804575ffcf6c8779512eb8cfae8b879eb80d0e;p=teleforma.git fix reminder, fix bad user destination in message --- diff --git a/teleforma/locale/fr/LC_MESSAGES/django.mo b/teleforma/locale/fr/LC_MESSAGES/django.mo index fd978ced..20590c42 100644 Binary files a/teleforma/locale/fr/LC_MESSAGES/django.mo and b/teleforma/locale/fr/LC_MESSAGES/django.mo differ 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 @@