taskapp/utilities/notification.py
changeset 78 c5bcafccc135
parent 57 67e0d0a915e3
child 123 a6b4234388c8
equal deleted inserted replaced
71:801cf8fca53a 78:c5bcafccc135
    12     notification.save()
    12     notification.save()
    13     notification.to = to
    13     notification.to = to
    14     notification.sub = subject
    14     notification.sub = subject
    15     notification.message = message
    15     notification.message = message
    16     notification.save()
    16     notification.save()
       
    17 
       
    18 def mark_notification_read(notification_id):
       
    19     """
       
    20     makes a notification identified by the notification_id read.
       
    21     arguments:
       
    22         notification_id - a number denoting the id of the Notification object
       
    23     """
       
    24     try:
       
    25         notification = Notification.objects.get(id = notification_id)
       
    26     except Notification.DoesNotExist:
       
    27         return False
       
    28     notification.is_read = True
       
    29     notification.save()
       
    30     return True
       
    31 
       
    32 def delete_notification(notification_id):
       
    33     """
       
    34     deletes a notification identified by the notification_id.
       
    35     arguments:
       
    36         notification_id - a number denoting the id of the Notification object
       
    37     """
       
    38     try:
       
    39         notification = Notification.objects.get(id = notification_id)
       
    40     except Notification.DoesNotExist:
       
    41         return False
       
    42     notification.deleted = True
       
    43     notification.save()
       
    44     return True