taskapp/events/task.py
changeset 156 7cad1e92713d
parent 154 420f974328cc
child 158 c43e0114e593
equal deleted inserted replaced
155:52958289d81f 156:7cad1e92713d
    25     if rem_comments:
    25     if rem_comments:
    26         task.comment_set.update(is_deleted=True)
    26         task.comment_set.update(is_deleted=True)
    27         task.comment_set.update(deleted_by=task.created_by)
    27         task.comment_set.update(deleted_by=task.created_by)
    28 
    28 
    29     task.published_datetime = datetime.now()
    29     task.published_datetime = datetime.now()
    30 
    30     task.save()
    31     task.save()
    31 
       
    32     pending_requests = task.request_task.filter(is_valid=True, is_replied=False)
       
    33     pending_requests.update(is_valid=False)
       
    34 
    32     return task
    35     return task
    33 
    36 
    34 def addSubTask(main_task, sub_task):
    37 def addSubTask(main_task, sub_task):
    35     """ add the task to subs attribute of the task and update its status.
    38     """ add the task to subs attribute of the task and update its status.
    36     sub task can be added only if a task is in UP/OP/LO state.
    39     sub task can be added only if a task is in UP/OP/LO state.
   231     pending_requests.update(is_valid=False)
   234     pending_requests.update(is_valid=False)
   232 
   235 
   233     ## generate notifications here
   236     ## generate notifications here
   234 
   237 
   235     for a_user in task.assigned_users.all():
   238     for a_user in task.assigned_users.all():
   236         create_notification(role="CD", sent_to=a_user, sent_from=marked_by, task=task)
   239         create_notification(role="CD", sent_to=a_user, sent_from=closed_by, task=task, remarks=reason)
   237 
   240 
   238     for a_user in task.claimed_users.all():
   241     for a_user in task.claimed_users.all():
   239         create_notification(role="CD", sent_to=a_user, sent_from=marked_by, task=task)
   242         create_notification(role="CD", sent_to=a_user, sent_from=closed_by, task=task, remarks=reason)
   240 
   243 
   241     for a_mentor in task.mentors.all():
   244     for a_mentor in task.mentors.all():
   242         create_notification(role="CD", sent_to=a_mentor, sent_from=marked_by, task=task)
   245         create_notification(role="CD", sent_to=a_mentor, sent_from=closed_by, task=task, remarks=reason)
   243 
   246 
   244 
   247