]> git.parisson.com Git - teleforma.git/commitdiff
add message to user when a question is validated
authoryomguy <yomguy@parisson.com>
Tue, 15 Jan 2013 16:01:53 +0000 (17:01 +0100)
committeryomguy <yomguy@parisson.com>
Tue, 15 Jan 2013 16:01:53 +0000 (17:01 +0100)
teleforma/templates/postman/seminar_validated.txt [new file with mode: 0644]
teleforma/views/core.py
teleforma/views/pro.py

diff --git a/teleforma/templates/postman/seminar_validated.txt b/teleforma/templates/postman/seminar_validated.txt
new file mode 100644 (file)
index 0000000..438f54b
--- /dev/null
@@ -0,0 +1,6 @@
+{% load i18n %}{% load telemeta_utils %}{% load teleforma_tags %}
+{% trans 'Congratulations!' %}
+
+{% trans 'You can continue to the next step of your seminar following this link' %}: 
+                           
+http://{{ site.name }}{{ seminar_url }}
index 36a0878c3e1b733f069e5f2768b85a6212f7abdd..1485eb9a09b2ebf546987f5a2736e69d1e3dfa0f 100644 (file)
@@ -89,6 +89,8 @@ try:
 except:
     pass
 
+from postman.models import *
+from postman.utils import email_visitor, notify_user
 
 access_error = _('Access not allowed.')
 contact_message = _('Please login or contact the website administator to get a private access.')
index e909ff15a069d247c24d1f66840cb5a1037bf2d0..388650dca6d40966df7c1df731e080b5dacfdb8a 100644 (file)
@@ -47,6 +47,7 @@ from django.template.context import Context
 from django.utils.html import escape
 from django.views.generic.detail import SingleObjectMixin
 from django.core.mail import EmailMessage
+from django.template.loader import render_to_string
 
 import os
 from cgi import escape
@@ -238,22 +239,31 @@ class AnswersView(ListView):
         answer = Answer.objects.get(id=id)
         answer.validate()
         user = answer.user
+        sender = request.user
         seminar = answer.question.seminar
         if seminar_validated(user, seminar):
             testimonial = Testimonial(user=user, seminar=seminar)
             testimonial.save()
-            email = EmailMessage()
-            text = 'Your training testimonial for the seminar : '
-            email.subject = seminar.course.department.name + ' : ' + text + seminar.title
-            name, email.from_email = settings.ADMINS[0]
-            email.to = [user.email]
-            email.body = 'You have validated your training!'
-            email.send()
-
+            site = Site.objects.get_current()
+            seminar_url = reverse('teleforma-seminar-detail', kwargs={'pk':seminar.id})
+            ctx_dict = {'site': site, 'seminar_url': seminar_url,}
+            text = render_to_string('postman/seminar_validated.txt', ctx_dict)
+            mess = Message(sender=sender, recipient=user, 
+                           subject=_('Your answer has been validated'),
+                           body=text)
+            mess.moderation_status = 'a'
+            mess.save()
+            notify_user(mess, 'acceptance')
 
     @jsonrpc_method('teleforma.reject_answer')
     def reject(request, id):
         answer = Answer.objects.get(id=id)
+        seminar = answer.question.seminar
+        user = answer.user
+        testimonials = Testimonial.objects.filter(user=user, seminar=seminar)
+        if testimonials:
+            for testimonial in testimonials:
+                testimonial.delete()
         answer.validated = False
         answer.status = 2
         answer.save()