scripts/mails.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Sat, 05 Dec 2009 09:39:02 +0530
changeset 44 c390adb66ba6
parent 42 efacdf0cd268
child 45 a7cb2566be42
permissions -rw-r--r--
Sponsorship for speakers mail.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
"""Helper script to send emails to the users to remind of the
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
registration and inform them to complete their profiles and stuff.
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
"""
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
__authors__ = [
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
  '"Madhusudan.C.S" <madhusudancs@gmail.com>',
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
  ]
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
from django.template import loader
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
from project.kiwipycon.talk.models import Talk
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
def speaker_accepted():
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
    """Sends a mail to each speaker whose talk has been accepted
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
    informing them about the same.
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
    """
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
    talks = Talk.objects.all()
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
    template = 'notifications/speaker_accepted_mail.html'
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
    for talk in talks:
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
        subject = 'Your talk has been selected for SciPy.in 2009!'
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
        message = loader.render_to_string(
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
            template, dictionary={'name': talk.speaker.username,
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
                                  'title': talk.title})
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    31
        talk.speaker.email_user(subject=subject, message=message,
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
                                from_email='admin@scipy.in')
44
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    33
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    34
def speaker_sponsorship():
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    35
    """Sends a mail to each speaker whose talk has been accepted
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    36
    informing them about the their sponsorship.
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    37
    """
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    38
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    39
    talks = Talk.objects.all()
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    40
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    41
    template = 'notifications/speaker_sponsorship_mail.html'
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    42
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    43
    for talk in talks:
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    44
        subject = 'Details regarding your travel and accommodation for SciPy.in 2009'
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    45
        message = loader.render_to_string(
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    46
            template, dictionary={'name': talk.speaker.username,
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    47
                                  'title': talk.title})
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    48
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    49
        talk.speaker.email_user(subject=subject, message=message,
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    50
                                from_email='admin@scipy.in')