]> git.parisson.com Git - teleforma.git/commitdiff
fix
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 6 Dec 2013 23:29:29 +0000 (00:29 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 6 Dec 2013 23:29:29 +0000 (00:29 +0100)
teleforma/management/commands/teleforma-message-all-seminar-users.py

index 8597221496dee78e0f461ea1c32157c17f8278de..f950a8058ac26a4df0fb1d65f4426ab5425f4bcd 100644 (file)
@@ -35,40 +35,41 @@ class Command(BaseCommand):
             auditor = user.auditor.all()
             professor = user.professor.all()
 
-            if auditor and not professor and user.is_active and user.email and seminar.expiry_date:
+            if auditor and not professor and user.is_active and user.email:
                 auditor = auditor[0]
                 seminars = auditor.seminars.all()
                 for seminar in seminars:
-                    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.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 seminar.sub_title:
+                                title = seminar.sub_title + ' : ' + seminar.title
+                            else:
+                                title = seminar.title
 
-                        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)
+                            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)
 
-                        mess = Message(sender=sender, recipient=user, subject=subject[:119], body=text)
-                        mess.moderation_status = 'a'
-                        mess.save()
-                        #notify_user(mess, 'acceptance')
-                        
-                        print user.username, seminar.title
+                            mess = Message(sender=sender, recipient=user, subject=subject[:119], body=text)
+                            mess.moderation_status = 'a'
+                            mess.save()
+                            #notify_user(mess, 'acceptance')
+                            
+                            print user.username, seminar.title