fnp
/
edumed.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a51aa3c
)
email only selected teachers
author
Jan Szejko
<janek37@gmail.com>
Wed, 22 Nov 2017 12:55:15 +0000
(13:55 +0100)
committer
Jan Szejko
<janek37@gmail.com>
Wed, 22 Nov 2017 12:55:15 +0000
(13:55 +0100)
wtem/management/commands/wtem_email_teachers.py
patch
|
blob
|
history
diff --git
a/wtem/management/commands/wtem_email_teachers.py
b/wtem/management/commands/wtem_email_teachers.py
index
40773f0
..
c8e95c3
100644
(file)
--- a/
wtem/management/commands/wtem_email_teachers.py
+++ b/
wtem/management/commands/wtem_email_teachers.py
@@
-12,17
+12,20
@@
class Command(BaseCommand):
sent = 0
failed = 0
sent = 0
failed = 0
-
query
= Contact.objects.filter(form_tag='olimpiada').order_by('contact').distinct('contact')
+
contacts
= Contact.objects.filter(form_tag='olimpiada').order_by('contact').distinct('contact')
template_name = args[0]
template_name = args[0]
+ emails = args[1:]
+ if emails:
+ contacts = contacts.filter(contact__in=emails)
message = render_to_string('wtem/' + template_name + '.txt')
subject = render_to_string('wtem/' + template_name + '_subject.txt')
answer = raw_input(
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?' %
- (
query
.count(), subject.encode('utf8'), message.encode('utf8')))
+ 'Send the following to %d teachers with subject "%s"\n\n%s\n\n?' %
+ (
contacts
.count(), subject.encode('utf8'), message.encode('utf8')))
if answer == 'yes':
if answer == 'yes':
- for contact in
query
:
+ for contact in
contacts
:
try:
self.send_message(message, subject, contact.contact)
except Exception as e:
try:
self.send_message(message, subject, contact.contact)
except Exception as e: