]> git.parisson.com Git - teleforma.git/commitdiff
fix user seminar lists
authoryomguy <yomguy@parisson.com>
Sat, 29 Dec 2012 17:40:53 +0000 (18:40 +0100)
committeryomguy <yomguy@parisson.com>
Sat, 29 Dec 2012 17:40:53 +0000 (18:40 +0100)
teleforma/context_processors.py
teleforma/templates/telemeta/profile_detail.html
teleforma/templatetags/teleforma_tags.py
teleforma/views/pro.py

index d151460631a2359313766ae1c76abe8cc4f9448b..b844a4d6ca96b51db71352986749ec83e02ba9d9 100644 (file)
@@ -78,7 +78,11 @@ def seminar_validated(user, seminar):
 
 def all_seminars(request, progress_order=False):
     seminars = []
-    user = request.user
+
+    if isinstance(request, User):
+        user = request
+    else:
+        user = request.user
     
     if not user.is_authenticated():
         return {}
index 53bd0212303d6c2b27c1643490c1f76c9f898d7d..08b2c0d1ec1517ce5bc11f54f13a13283118945e 100644 (file)
   {% block modules %}
 
     <div class="module">
-    <h3><a href="{% url teleforma-desk %}"><img src="{{ STATIC_URL }}telemeta/images/module_playlist.png" alt="playlists" style="vertical-align:middle" />{% if user.username != usr.username%}{% trans "His courses" %}{% else %}{% trans "My courses" %}{% endif %}</a></h3>
+    <h3><a href="{% url teleforma-desk %}"><img src="{{ STATIC_URL }}telemeta/images/module_playlist.png" alt="playlists" style="vertical-align:middle" />{% if user.username != usr.username%}{% trans "His seminars" %}{% else %}{% trans "My seminars" %}{% endif %}</a></h3>
     <div style="background: white;">
     <ul>
     {% block courses %}
-    {% with usr|user_courses as courses %}
-     {% for c in courses %}
-       {% with c.course as course %}
-       <li><a href="{% url teleforma-course-detail course.id %}">{{ course.title}} {{ course.type }}</a></li>
-       {% endwith %}
-     {% endfor %}
+    {% with usr|user_seminars as seminars %}
+     <ul>
+      {% for seminar in seminars %}
+      <li><a href="{% url teleforma-seminar-detail seminar.id %}">{{ seminar.title }}</a></li>
+      {% endfor %}
+    </ul>
     {% endwith %}
     {% endblock courses %}
     </ul>
index 742cd37fdd1ac4d6613275d64473ed392c4d907a..7c0cd18a1cec6de57a740e7b16091a14699cc0e5 100644 (file)
@@ -53,7 +53,7 @@ import django.utils.timezone as timezone
 from timezones.utils import localtime_for_timezone
 from django.utils.translation import ugettext_lazy as _
 from teleforma.views import get_courses
-from teleforma.views.pro import seminar_progress
+from teleforma.context_processors import *
 from urlparse import urlparse
 
 register = template.Library()
@@ -252,6 +252,8 @@ def progress(seminar, user):
 @register.filter
 def in_download_formats(file):
     ext = os.path.splitext(file)[1][1:]
-    print ext
     return ext in settings.TELEMETA_DOWNLOAD_FORMATS
     
+@register.filter
+def user_seminars(user):
+    return all_seminars(user)['all_seminars']
index 3fd4445e7a767656af73f90ec27b255aa80c600d..d82e9840d459f6424966eea7599a2d33426d024a 100644 (file)
@@ -254,17 +254,15 @@ class AnswersView(ListView):
         answer = Answer.objects.get(id=id)
         answer.validate()
         user = answer.user
-        seminar = answer.question.get().seminar
+        seminar = answer.question.seminar
         if seminar_validated(user, seminar):
             email = EmailMessage()
-            email.subject = seminar.course.department.name + ' : ' + \
-                    _('Your training testimonial for the seminar : ') + seminar.title
-            email.from_email = settings.ADMINS[0][1]
-            email.to = user.email
-            email.body = _('You have validated your training!')
-            email.attach()
-            
-
+            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()
 
     @jsonrpc_method('teleforma.reject_answer')
     def reject(request, id):