author | anoop |
Wed, 24 Feb 2010 17:23:25 +0530 | |
changeset 81 | cade14d25a58 |
parent 78 | c5bcafccc135 |
child 123 | a6b4234388c8 |
permissions | -rw-r--r-- |
57 | 1 |
from pytask.taskapp.models import Notification |
2 |
from datetime import datetime |
|
3 |
||
4 |
def create_notification(to,subject,message): |
|
5 |
""" |
|
6 |
creates a notification based on the passed arguments. |
|
7 |
to - a list of users to which the notification is to be sent |
|
8 |
subject - subject of the notification message to be sent |
|
9 |
message - message body of the notification |
|
10 |
""" |
|
11 |
notification = Notification(sent_date = datetime.now()) |
|
12 |
notification.save() |
|
13 |
notification.to = to |
|
14 |
notification.sub = subject |
|
15 |
notification.message = message |
|
16 |
notification.save() |
|
78
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
17 |
|
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
18 |
def mark_notification_read(notification_id): |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
19 |
""" |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
20 |
makes a notification identified by the notification_id read. |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
21 |
arguments: |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
22 |
notification_id - a number denoting the id of the Notification object |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
23 |
""" |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
24 |
try: |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
25 |
notification = Notification.objects.get(id = notification_id) |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
26 |
except Notification.DoesNotExist: |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
27 |
return False |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
28 |
notification.is_read = True |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
29 |
notification.save() |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
30 |
return True |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
31 |
|
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
32 |
def delete_notification(notification_id): |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
33 |
""" |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
34 |
deletes a notification identified by the notification_id. |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
35 |
arguments: |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
36 |
notification_id - a number denoting the id of the Notification object |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
37 |
""" |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
38 |
try: |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
39 |
notification = Notification.objects.get(id = notification_id) |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
40 |
except Notification.DoesNotExist: |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
41 |
return False |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
42 |
notification.deleted = True |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
43 |
notification.save() |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
57
diff
changeset
|
44 |
return True |