From: Guillaume Pellerin Date: Fri, 6 Dec 2013 23:29:29 +0000 (+0100) Subject: fix X-Git-Tag: 2.8.1-pro~472^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=66cab96fcf24fe6836b2e7e474308e87c3a1e609;p=teleforma.git fix --- diff --git a/teleforma/management/commands/teleforma-message-all-seminar-users.py b/teleforma/management/commands/teleforma-message-all-seminar-users.py index 85972214..f950a805 100644 --- a/teleforma/management/commands/teleforma-message-all-seminar-users.py +++ b/teleforma/management/commands/teleforma-message-all-seminar-users.py @@ -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