added option of specifying if previous mentors and comments must be removed in publish task event.
authornishanth
Fri, 26 Feb 2010 11:34:17 +0530
changeset 113 ea962d5fe99e
parent 112 eadff01e395e
child 114 38793914921b
added option of specifying if previous mentors and comments must be removed in publish task event.
taskapp/events/task.py
--- a/taskapp/events/task.py	Fri Feb 26 11:29:25 2010 +0530
+++ b/taskapp/events/task.py	Fri Feb 26 11:34:17 2010 +0530
@@ -2,7 +2,7 @@
 from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim, Map
 from pytask.taskapp.utilities.request import create_request
 
-def publishTask(task):
+def publishTask(task, rem_mentors=True, rem_comments=True):
     """ set the task status to open """
 
     if task.sub_type == 'D':
@@ -15,11 +15,13 @@
     else:
         task.status = "OP"
 
-    task.mentors.clear()
-    task.mentors.add(task.created_by)
+    if rem_mentors:
+        task.mentors.clear()
+        task.mentors.add(task.created_by)
 
-    task.comment_set.update(is_deleted=True)
-    task.comment_set.update(deleted_by=task.created_by)
+    if rem_comments:
+        task.comment_set.update(is_deleted=True)
+        task.comment_set.update(deleted_by=task.created_by)
 
     task.save()
     return task