summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhusudan.C.S2011-01-21 19:47:43 +0530
committerMadhusudan.C.S2011-01-21 19:47:43 +0530
commitbf5c33a323fbfa790ef32c2036a738f4e04bf88e (patch)
treed3332acf84080a8a7be0db1161c9ac6f8c4f28a3
parent51a9a21eb7d507f0aac0b8d5cb3d522d99635480 (diff)
downloadpytask-bf5c33a323fbfa790ef32c2036a738f4e04bf88e.tar.gz
pytask-bf5c33a323fbfa790ef32c2036a738f4e04bf88e.tar.bz2
pytask-bf5c33a323fbfa790ef32c2036a738f4e04bf88e.zip
Add a script for sending email to users.
-rw-r--r--scripts/mails.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/mails.py b/scripts/mails.py
new file mode 100644
index 0000000..ce57bce
--- /dev/null
+++ b/scripts/mails.py
@@ -0,0 +1,35 @@
+"""Helper script to send emails to the users.
+"""
+
+
+__authors__ = [
+ '"Madhusudan.C.S" <madhusudancs@gmail.com>',
+ ]
+
+
+from django.template import loader
+from django.contrib.auth.models import User
+from django.utils.translation import ugettext
+
+
+def textbook_workshop_remainder(subject_template=None, body_template=None):
+ """Sends a mail to each delegate about the template content specified.
+ """
+
+ users = User.objects.all()
+
+ subject = loader.render_to_string(subject_template)
+
+ for user in users:
+ profile = user.getprofile()
+ if profile:
+ full_name = profile.name
+ else:
+ full_name = ''
+
+ message = loader.render_to_string(
+ body_template, dictionary={'name': full_name})
+
+ user.email_user(subject=subject, message=message,
+ from_email='madhusudancs@fossee.in')
+