# HG changeset patch # User Madhusudan.C.S # Date 1295619463 -19800 # Node ID 288d1dfb81c0fd22eb4f410f4b302add92a7fcc4 # Parent 438afe31fffdc702ec5530b90a5eaef56b769030 Add a script for sending email to users. diff -r 438afe31fffd -r 288d1dfb81c0 scripts/mails.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/mails.py Fri Jan 21 19:47:43 2011 +0530 @@ -0,0 +1,35 @@ +"""Helper script to send emails to the users. +""" + + +__authors__ = [ + '"Madhusudan.C.S" ', + ] + + +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') +