taskapp/utilities/notification.py
author anoop
Tue, 23 Feb 2010 14:31:54 +0530
changeset 57 67e0d0a915e3
child 78 c5bcafccc135
permissions -rw-r--r--
added utilities for creating notification.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     1
from pytask.taskapp.models import Notification
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     2
from datetime import datetime
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     3
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     4
def create_notification(to,subject,message):
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     5
    """
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     6
    creates a notification based on the passed arguments.
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     7
        to - a list of users to which the notification is to be sent
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     8
        subject - subject of the notification message to be sent
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
     9
        message - message body of the notification
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
    10
    """
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
    11
    notification = Notification(sent_date = datetime.now())
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
    12
    notification.save()
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
    13
    notification.to = to
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
    14
    notification.sub = subject
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
    15
    notification.message = message
67e0d0a915e3 added utilities for creating notification.
anoop
parents:
diff changeset
    16
    notification.save()