now task page displays only undeleted comments. and publish task removes previous comments.
authornishanth
Fri, 26 Feb 2010 11:29:25 +0530
changeset 112 eadff01e395e
parent 111 c272d4c601cd
child 113 ea962d5fe99e
now task page displays only undeleted comments. and publish task removes previous comments.
taskapp/events/task.py
taskapp/models.py
taskapp/views/task.py
--- a/taskapp/events/task.py	Fri Feb 26 02:52:32 2010 +0530
+++ b/taskapp/events/task.py	Fri Feb 26 11:29:25 2010 +0530
@@ -17,6 +17,10 @@
 
     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)
+
     task.save()
     return task
 
--- a/taskapp/models.py	Fri Feb 26 02:52:32 2010 +0530
+++ b/taskapp/models.py	Fri Feb 26 11:29:25 2010 +0530
@@ -107,7 +107,7 @@
     created_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
     creation_datetime = models.DateTimeField()
     deleted_by = models.ForeignKey(User, null = True, blank = True, related_name = "%(class)s_deleted_by")
-    deleted = models.BooleanField()
+    is_deleted = models.BooleanField()
     attachment = models.FileField(upload_to = UPLOADS_DIR, blank = True)
     
     def __unicode__(self):
--- a/taskapp/views/task.py	Fri Feb 26 02:52:32 2010 +0530
+++ b/taskapp/views/task.py	Fri Feb 26 11:29:25 2010 +0530
@@ -61,7 +61,7 @@
 
     if task.status == "DL":
         return show_msg(user, 'This task no longer exists', '/task/browse/','browse the tasks')
-    comments = Comment.objects.filter(task=task)
+    comments = task.comment_set.filter(is_deleted=False)
     mentors = task.mentors.all()
 
     deps, subs = task.deps, task.subs