fnp
/
edumed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
framed tables
[edumed.git]
/
wtem
/
management
/
commands
/
wtem_email_teachers.py
diff --git
a/wtem/management/commands/wtem_email_teachers.py
b/wtem/management/commands/wtem_email_teachers.py
index
3aba80d
..
9b5e5e9
100644
(file)
--- a/
wtem/management/commands/wtem_email_teachers.py
+++ b/
wtem/management/commands/wtem_email_teachers.py
@@
-1,14
+1,10
@@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
-import sys
-from optparse import make_option
-
-from django.core.management.base import BaseCommand, CommandError
-from django.conf import settings
-from django.core.mail import send_mail
+from django.core.management.base import BaseCommand
from django.template.loader import render_to_string
from contact.models import Contact
from django.template.loader import render_to_string
from contact.models import Contact
+from wtem.management.commands import send_mail
class Command(BaseCommand):
class Command(BaseCommand):
@@
-16,12
+12,13
@@
class Command(BaseCommand):
sent = 0
failed = 0
sent = 0
failed = 0
- query = Contact.objects.filter(form_tag
=
'wtem').order_by('contact').distinct('contact')
+ query = Contact.objects.filter(form_tag
=
'wtem').order_by('contact').distinct('contact')
template_name = args[0]
message = render_to_string('wtem/' + template_name + '.txt')
subject = render_to_string('wtem/' + template_name + '_subject.txt')
template_name = args[0]
message = render_to_string('wtem/' + template_name + '.txt')
subject = render_to_string('wtem/' + template_name + '_subject.txt')
- answer = raw_input('Send the following to %d teachers with subject "%s"\n\n %s\n\n?' % \
+ answer = raw_input(
+ 'Send the following to %d teachers with subject "%s"\n\n %s\n\n?' %
(query.count(), subject.encode('utf8'), message.encode('utf8')))
if answer == 'yes':
(query.count(), subject.encode('utf8'), message.encode('utf8')))
if answer == 'yes':
@@
-39,11
+36,5
@@
class Command(BaseCommand):
def send_message(self, message, subject, email):
self.stdout.write('>>> sending to %s' % email)
def send_message(self, message, subject, email):
self.stdout.write('>>> sending to %s' % email)
- send_mail(
- subject,
- message,
- getattr(settings, 'WTEM_CONTACT_EMAIL', 'no-reply@edukacjamedialna.edu.pl'),
- [email],
- fail_silently=False
- )
+ send_mail(subject=subject, body=message, to=[email])