scripts/mails.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Tue, 08 Dec 2009 12:21:09 +0530
changeset 48 bb835205604b
parent 47 668e7e0881b6
child 61 959ec5eaafb1
permissions -rw-r--r--
Summary of individual events mail to all users.
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
48
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    12
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
    13
48
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    14
from project.kiwipycon.registration.models import Registration
42
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
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
    16
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
def speaker_accepted():
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
    """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
    20
    informing them about the same.
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
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
    talks = Talk.objects.all()
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
    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
    26
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
    for talk in talks:
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
        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
    29
        message = loader.render_to_string(
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
            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
    31
                                  'title': talk.title})
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
efacdf0cd268 Added template which sends the accepted speakes a mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    33
        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
    34
                                from_email='admin@scipy.in')
44
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    35
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    36
44
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    37
def speaker_sponsorship():
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    38
    """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
    39
    informing them about the their sponsorship.
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
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    42
    talks = Talk.objects.all()
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    43
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    44
    template = 'notifications/speaker_sponsorship_mail.html'
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    45
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    46
    for talk in talks:
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    47
        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
    48
        message = loader.render_to_string(
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    49
            template, dictionary={'name': talk.speaker.username,
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    50
                                  'title': talk.title})
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    51
c390adb66ba6 Sponsorship for speakers mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 42
diff changeset
    52
        talk.speaker.email_user(subject=subject, message=message,
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    53
                                from_email='admin@scipy.in')
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
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    56
def delegate_remainder():
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    57
    """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
    58
    informing them about the their sponsorship.
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
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    61
    regs = User.objects.all()
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    62
47
668e7e0881b6 Made some typo fixes to delegate reminder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 46
diff changeset
    63
    template = 'notifications/reminder_mail.html'
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    64
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    65
    for reg in regs:
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    66
        subject = 'SciPy.in 2009: Remainder and details'
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    67
        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
    68
            template, dictionary={'name': reg.username})
45
a7cb2566be42 Delegate remainder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    69
47
668e7e0881b6 Made some typo fixes to delegate reminder mail.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 46
diff changeset
    70
        reg.email_user(subject=subject, message=message,
48
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    71
                       from_email='madhusudancs@gmail.com')
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    72
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    73
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    74
def delegate_about_event():
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    75
    """Sends a mail to each confirmed delegate informing
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    76
    them about the the individual events.
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    77
    """
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    78
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    79
    regs = Registration.objects.all()
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    80
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    81
    template = 'notifications/sprints_about_mail.html'
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    82
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    83
    for reg in regs:
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    84
        subject = 'SciPy.in 2009: Details of the individual events'
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    85
        message = loader.render_to_string(
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    86
            template, dictionary={'name': reg.registrant.username})
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    87
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    88
        reg.registrant.email_user(subject=subject, message=message,
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    89
                                  from_email='madhusudancs@gmail.com')
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    90
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    91
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    92
def speaker_confirmation():
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    93
    """Sends a mail to each speaker asking for confirmation.
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    94
    """
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    95
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    96
    talks = Talk.objects.all()
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    97
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    98
    template = 'notifications/speaker_confirmation_mail.html'
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
    99
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
   100
    for talk in talks:
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
   101
        subject = 'SciPy.in 2009: Requesting for confirmation of your talk'
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
   102
        message = loader.render_to_string(
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
   103
            template, dictionary={'name': talk.speaker.username,
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
   104
                                  'title': talk.title})
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
   105
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
   106
        talk.speaker.email_user(subject=subject, message=message,
bb835205604b Summary of individual events mail to all users.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 47
diff changeset
   107
                                from_email='admin@scipy.in')