From 8f9406383064921f8cf50bad0a6d4f1bd06f9cb4 Mon Sep 17 00:00:00 2001
From: nishanth
Date: Fri, 26 Feb 2010 11:34:17 +0530
Subject: added option of specifying if previous mentors and comments must be
 removed in publish task event.

---
 taskapp/events/task.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'taskapp/events/task.py')

diff --git a/taskapp/events/task.py b/taskapp/events/task.py
index 9ed1450..308ed0f 100644
--- a/taskapp/events/task.py
+++ b/taskapp/events/task.py
@@ -2,7 +2,7 @@ from datetime import datetime
 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 @@ def publishTask(task):
     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
-- 
cgit