scripts/mails.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Sat, 05 Dec 2009 10:12:39 +0530
changeset 47 668e7e0881b6
parent 46 971ba6d7a529
child 48 bb835205604b
permissions -rw-r--r--
Made some typo fixes to delegate reminder 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
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    14
from django.contrib.auth.models import User
42
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
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
def speaker_accepted():
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
    """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
    19
    informing them about the same.
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
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
    talks = Talk.objects.all()
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
    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
    25
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
    for talk in talks:
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
        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
    28
        message = loader.render_to_string(
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
            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
    30
                                  'title': talk.title})
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    31
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
        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
    33
                                from_email='admin@scipy.in')
44
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    34
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    35
44
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    36
def speaker_sponsorship():
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    37
    """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
    38
    informing them about the their sponsorship.
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    39
    """
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
    talks = Talk.objects.all()
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
    template = 'notifications/speaker_sponsorship_mail.html'
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    44
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    45
    for talk in talks:
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    46
        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
    47
        message = loader.render_to_string(
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    48
            template, dictionary={'name': talk.speaker.username,
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    49
                                  'title': talk.title})
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    50
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    51
        talk.speaker.email_user(subject=subject, message=message,
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    52
                                from_email='admin@scipy.in')
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    53
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    54
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    55
def delegate_remainder():
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    56
    """Sends a mail to each speaker whose talk has been accepted
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    57
    informing them about the their sponsorship.
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    58
    """
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    59
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    60
    regs = User.objects.all()
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    61
47
668e7e0881b6 Made some typo fixes to delegate reminder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 46
diff changeset
    62
    template = 'notifications/reminder_mail.html'
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    63
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    64
    for reg in regs:
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    65
        subject = 'SciPy.in 2009: Remainder and details'
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    66
        message = loader.render_to_string(
47
668e7e0881b6 Made some typo fixes to delegate reminder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 46
diff changeset
    67
            template, dictionary={'name': reg.username})
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    68
47
668e7e0881b6 Made some typo fixes to delegate reminder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 46
diff changeset
    69
        reg.email_user(subject=subject, message=message,
668e7e0881b6 Made some typo fixes to delegate reminder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 46
diff changeset
    70
                       from_email='madhusudancs@gmail.com')