]> git.parisson.com Git - teleforma.git/commitdiff
fix reminder, fix bad user destination in message
authorGuillaume Pellerin <yomguy@parisson.com>
Mon, 9 Dec 2013 16:16:42 +0000 (17:16 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Mon, 9 Dec 2013 16:16:42 +0000 (17:16 +0100)
teleforma/locale/fr/LC_MESSAGES/django.mo
teleforma/locale/fr/LC_MESSAGES/django.po
teleforma/management/commands/teleforma-message-all-seminar-users.py
teleforma/templates/postman/base_write.html
teleforma/templates/teleforma/messages/seminar_remind.txt

index fd978ced30fcef526f2fdf52ba21e99e7b82e671..20590c425ee35d22d844e0bb23cb8f96ced0ae66 100644 (file)
Binary files a/teleforma/locale/fr/LC_MESSAGES/django.mo and b/teleforma/locale/fr/LC_MESSAGES/django.mo differ
index 4202904400c04909f67007bc7807a852e79de519..54a9c52c75e3d0fa99cabb81fe43edd0b15c6ac0 100644 (file)
@@ -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 <yomguy@parisson.com>\n"
 "Language-Team: LANGUAGE <lists@parisson.com>\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"
 
index c26a6e00fa294927937c6854a0ffcd53ba7aa5d2..b631e33eaae58ff92200ab2b1cede55b32abac9f 100644 (file)
@@ -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
 
index f4d7bfafa3f23b92984666ea6df98e0411e6c832..40c4f22f58d1ec00d3fa89f3736b10fd24eb8db6 100644 (file)
 <script type="text/javascript">document.getElementById("id_subject").focus();</script>
 <script type="text/javascript">
 
+{% if not user.is_superuser %}
 $(window).ready(function(){
       var recipient = '{% admin_username %}';
       $("#id_recipients").val(recipient);
     });
+{% endif %}
 
 $('#send_button').click(function() {
   $('#_messageForm').submit();
index 1e5722072e5fee885d122ae766476a5a47073cac..f97382d4463fb2ccb257cb6b36234ad7a2d3bb76 100644 (file)
@@ -1,10 +1,14 @@
 {% load i18n %}{% autoescape off %}{% blocktrans %}{{ gender }} {{ last_name }},
 
-votre abonnement au séminaire e-learning "{{ title }}" arrive à expiration le {{ date }}.
+Certains de vos séminaires e-learning arrivent bientôt à expiration :{% endblocktrans %}
 
-Nous vous rappelons que vous devez achever votre formation avant cette date.
+{% for seminar in seminars %}
+ * "{% if seminar.sub_title %}{{ seminar.sub_title }}{% else %}{{ seminar.title }}{% endif %}" {% trans "expires on" %} {{ seminar.expiry_date }}.
+{% endfor %}
+{% blocktrans %}
+Nous vous rappelons que vous devez achever vos formations avant ces dates.
 
-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 }}."
+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 {{ organization }} jusqu'aux dates d'expiration de chaque séminaire."
 
 The team of the {{ organization }} thank you for your confidence and we remain at your disposal for further information.
 {% endblocktrans %}{% endautoescape %}