taskapp/utilities/notification.py
changeset 156 7cad1e92713d
parent 153 925af1b4ee65
child 161 74ef330c9185
equal deleted inserted replaced
155:52958289d81f 156:7cad1e92713d
    50                 notification.message += "Reason: %s<br />"%remarks
    50                 notification.message += "Reason: %s<br />"%remarks
    51             notification.message += "<br />"
    51             notification.message += "<br />"
    52 
    52 
    53     elif role == "MT":
    53     elif role == "MT":
    54 
    54 
       
    55         notification.task = task
       
    56         notification.sent_from = sent_from
       
    57 
    55         task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title)
    58         task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title)
    56         requested_mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username)
    59         requested_mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username)
    57         new_mentor = sent_from
    60         new_mentor = sent_from
    58         new_mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(new_mentor.id, new_mentor.username)
    61         new_mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(new_mentor.id, new_mentor.username)
    59         
    62         
    68             if remarks:
    71             if remarks:
    69                 notification.message += "Remarks: %s<br />"%remarks
    72                 notification.message += "Remarks: %s<br />"%remarks
    70 
    73 
    71     elif role in ["DV", "MG", "AD"]:
    74     elif role in ["DV", "MG", "AD"]:
    72 
    75 
       
    76         notification.sent_from = sent_from
       
    77 
    73         accepting_user = sent_from
    78         accepting_user = sent_from
    74         user_url = '<a href="/user/view/uid=%s">%s</a>'%(accepting_user.id, accepting_user.username) ## i mean the user who has accepted it
    79         user_url = '<a href="/user/view/uid=%s">%s</a>'%(accepting_user.id, accepting_user.username) ## i mean the user who has accepted it
    75         requested_by_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username)
    80         requested_by_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username)
    76         role_rights = dict(RIGHTS_CHOICES)[role]
    81         role_rights = dict(RIGHTS_CHOICES)[role]
    77         role_learn_url = "/about/%s"%role_rights.lower()
    82         role_learn_url = "/about/%s"%role_rights.lower()
    86             if remarks:
    91             if remarks:
    87                 notification.message += "Remarks: %s<br />"%remarks
    92                 notification.message += "Remarks: %s<br />"%remarks
    88 
    93 
    89     elif role == "NT":
    94     elif role == "NT":
    90 
    95 
       
    96         notification.task = task
    91         new_mentor = sent_to
    97         new_mentor = sent_to
    92         mentor_learn_url = '<sup><a href="/about/mentor">learn more</a></sup>'
    98         mentor_learn_url = '<sup><a href="/about/mentor">learn more</a></sup>'
    93         task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title)
    99         task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title)
    94 
   100 
    95         notification.sub = "You are mentoring the task %s"%task.title[:20]
   101         notification.sub = "You are mentoring the task %s"%task.title[:20]
   108                 notification.message += "<li> %s - %s </li>"%(a_user.username, a_user.email)
   114                 notification.message += "<li> %s - %s </li>"%(a_user.username, a_user.email)
   109             notification.message += "</ul><br />"
   115             notification.message += "</ul><br />"
   110         notification.message += "Happy Mentoring."
   116         notification.message += "Happy Mentoring."
   111 
   117 
   112     elif role in ["CM", "CD"]:
   118     elif role in ["CM", "CD"]:
       
   119 
       
   120         notification.sent_from = sent_from
       
   121         notification.role = role
       
   122         notification.task = task
       
   123         notification.remarks = remarks
       
   124 
   113         mentor = sent_from
   125         mentor = sent_from
   114         mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(mentor.id, mentor.username)
   126         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)
   127         task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title)
   116         
   128         
   117         if role == "CM":
   129         if role == "CM":