taskapp/utilities/notification.py
changeset 153 925af1b4ee65
parent 150 604808d27483
child 156 7cad1e92713d
equal deleted inserted replaced
152:a65e1ef725dd 153:925af1b4ee65
   100             notification.message += "<li> %s - %s </li>"%(a_mentor.username, a_mentor.email)
   100             notification.message += "<li> %s - %s </li>"%(a_mentor.username, a_mentor.email)
   101         notification.message += "</ul>"
   101         notification.message += "</ul>"
   102 
   102 
   103         working_users = task.assigned_users.all()
   103         working_users = task.assigned_users.all()
   104         if working_users:
   104         if working_users:
   105             notification_message += "List of users working on the task.<br />"
   105             notification.message += "List of users working on the task.<br />"
   106             notification_message += "<ul>"
   106             notification.message += "<ul>"
   107             for a_user in working_users:
   107             for a_user in working_users:
   108                 notification.message += "<li> %s - %s </li>"%(a_user.username, a_user.email)
   108                 notification.message += "<li> %s - %s </li>"%(a_user.username, a_user.email)
   109             notification.message += "</ul><br />"
   109             notification.message += "</ul><br />"
   110         notification.message += "Happy Mentoring."
   110         notification.message += "Happy Mentoring."
       
   111 
       
   112     elif role in ["CM", "CD"]:
       
   113         mentor = sent_from
       
   114         mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(mentor.id, mentor.username)
       
   115         task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title)
       
   116         
       
   117         if role == "CM":
       
   118             notification.sub = "%s has been marked complete"%task.title
       
   119             notification.message = "The task %s has been marked complete by %s.<br />"%(task_url, mentor_url)
       
   120 
       
   121         elif role == "CD":
       
   122             notification.sub = "%s has been closed"%task.title
       
   123             notification.message = "The task %s has been closed by %s.<br />"%(task_url, mentor_url)
       
   124 
       
   125         if remarks:
       
   126             notification.message += "<b>Remarks:</b> %s"%remarks
       
   127 
   111 
   128 
   112     notification.save()
   129     notification.save()
   113 
   130 
   114 def mark_notification_read(notification_id):
   131 def mark_notification_read(notification_id):
   115     """
   132     """