taskapp/events/task.py
changeset 167 b61e45074ba1
parent 166 ac72d641046e
child 189 8f5fb15ffd9b
equal deleted inserted replaced
166:ac72d641046e 167:b61e45074ba1
   228         create_notification(role="CM", sent_to=a_user, sent_from=marked_by, task=task)
   228         create_notification(role="CM", sent_to=a_user, sent_from=marked_by, task=task)
   229 
   229 
   230     for a_mentor in task.mentors.all():
   230     for a_mentor in task.mentors.all():
   231         create_notification(role="CM", sent_to=a_mentor, sent_from=marked_by, task=task)
   231         create_notification(role="CM", sent_to=a_mentor, sent_from=marked_by, task=task)
   232 
   232 
   233 
       
   234 
       
   235 def closeTask(task, closed_by, reason=None):
   233 def closeTask(task, closed_by, reason=None):
   236     """ set the status of task as CD.
   234     """ set the status of task as CD.
   237     generate notifications accordingly.
   235     generate notifications accordingly.
   238     """
   236     """
   239 
   237 
   252         create_notification(role="CD", sent_to=a_user, sent_from=closed_by, task=task, remarks=reason)
   250         create_notification(role="CD", sent_to=a_user, sent_from=closed_by, task=task, remarks=reason)
   253 
   251 
   254     for a_mentor in task.mentors.all():
   252     for a_mentor in task.mentors.all():
   255         create_notification(role="CD", sent_to=a_mentor, sent_from=closed_by, task=task, remarks=reason)
   253         create_notification(role="CD", sent_to=a_mentor, sent_from=closed_by, task=task, remarks=reason)
   256 
   254 
   257 
   255 def deleteTask(task, deleted_by, reason=None):
       
   256     """ set the task status as DL
       
   257     notify all its other viewers about the deleting of task.
       
   258     """
       
   259 
       
   260     task.status = "DL"
       
   261     task.save()
       
   262 
       
   263     pending_requests = task.request_task.filter(is_replied=False,is_valid=True)
       
   264     pending_requests.update(is_valid=False)
       
   265 
       
   266     for a_mentor in task.mentors.exclude(id=deleted_by.id):
       
   267         create_notification("DL", sent_to=a_mentor, sent_from=deleted_by, task=task, remarks=reason)