taskapp/events/task.py
changeset 113 ea962d5fe99e
parent 112 eadff01e395e
child 114 38793914921b
equal deleted inserted replaced
112:eadff01e395e 113:ea962d5fe99e
     1 from datetime import datetime
     1 from datetime import datetime
     2 from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim, Map
     2 from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim, Map
     3 from pytask.taskapp.utilities.request import create_request
     3 from pytask.taskapp.utilities.request import create_request
     4 
     4 
     5 def publishTask(task):
     5 def publishTask(task, rem_mentors=True, rem_comments=True):
     6     """ set the task status to open """
     6     """ set the task status to open """
     7 
     7 
     8     if task.sub_type == 'D':
     8     if task.sub_type == 'D':
     9         deps, subs = task.map_subs.all(), []
     9         deps, subs = task.map_subs.all(), []
    10     else:
    10     else:
    13     if subs or any(map(lambda t:t.status!="CM",deps)):
    13     if subs or any(map(lambda t:t.status!="CM",deps)):
    14         task.status = "LO"
    14         task.status = "LO"
    15     else:
    15     else:
    16         task.status = "OP"
    16         task.status = "OP"
    17 
    17 
    18     task.mentors.clear()
    18     if rem_mentors:
    19     task.mentors.add(task.created_by)
    19         task.mentors.clear()
    20 
    20         task.mentors.add(task.created_by)
    21     task.comment_set.update(is_deleted=True)
    21 
    22     task.comment_set.update(deleted_by=task.created_by)
    22     if rem_comments:
       
    23         task.comment_set.update(is_deleted=True)
       
    24         task.comment_set.update(deleted_by=task.created_by)
    23 
    25 
    24     task.save()
    26     task.save()
    25     return task
    27     return task
    26 
    28 
    27 def addSubTask(main_task, sub_task):
    29 def addSubTask(main_task, sub_task):