Added support for threaded comments
authorAaron Bentley <abentley@panoramicfeedback.com>
Tue, 4 Apr 2006 13:52:50 +0000 (09:52 -0400)
committerAaron Bentley <abentley@panoramicfeedback.com>
Tue, 4 Apr 2006 13:52:50 +0000 (09:52 -0400)
beweb/beweb/controllers.py
beweb/beweb/templates/edit_bug.kid

index 6c43ecb0747fea8c8296cf65e5c3aba7cdd84098..74c6a7da89f84ec997e2b2b403c43cccf8d55d39 100644 (file)
@@ -13,9 +13,9 @@ def project_tree(project):
     except KeyError:
         raise Exception("Unknown project %s" % project)
 
-def comment_url(project, bug, comment):
+def comment_url(project, bug, comment, **kwargs):
     return turbogears.url("/project/%s/bug/%s/comment/%s" %
-                          (project, bug, comment))
+                          (project, bug, comment), kwargs)
 
 class Comment(PrestHandler):
     @provide_action("action", "New comment")
@@ -27,6 +27,18 @@ class Comment(PrestHandler):
         raise cherrypy.HTTPRedirect(comment_url(comment=comment.uuid, 
                                     **comment_data))
 
+    @provide_action("action", "Reply")
+    def reply_comment(self, comment_data, comment, *args, **kwargs):
+        bug_tree = project_tree(comment_data['project'])
+        bug = bug_tree.get_bug(comment_data['bug'])
+        reply_comment = new_comment(bug, "")
+        reply_comment.in_reply_to = comment.uuid
+        reply_comment.save()
+        reply_data = dict(comment_data)
+        del reply_data["comment"]
+        raise cherrypy.HTTPRedirect(comment_url(comment=reply_comment.uuid, 
+                                    **reply_data))
+
     @provide_action("action", "Update")
     def update(self, comment_data, comment, comment_body, *args, **kwargs):
         comment.body = comment_body
index 774334e6868370adb66d685cd8bc57bd731932a8..960866d38e876a66a862f62a7d92dd14b938c7de 100644 (file)
@@ -1,6 +1,6 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <?python
-from libbe.bugdir import severity_levels, active_status, inactive_status
+from libbe.bugdir import severity_levels, active_status, inactive_status, thread_comments
 from libbe.utility import time_to_str 
 from beweb.controllers import bug_list_url, comment_url
 from beweb.config import people
@@ -67,13 +67,13 @@ def soft_pre(text):
 
 <body>
 <h1>Edit bug</h1>
-<form method="post">
+<form method="post" action=".">
 <table>
 <tr><td>Status</td><td>Severity</td><td>Assigned To</td><td>Summary</td></tr>
 <tr><td>${select_among("status", active_status+inactive_status, bug.status)}</td><td>${select_among("severity", severity_levels, bug.severity)}</td>
 <td>${select_among("assigned", people.keys()+[None], bug.assigned, people)}</td><td><input name="summary" value="${bug.summary}" size="80" /></td></tr>
 </table>
-<div py:for="comment in bug.list_comments()" class="comment">
+<div py:def="show_comment(comment, children)" class="comment">
     <insetbox>
     <table>
         <tr><td>From</td><td>${comment.From}</td></tr>
@@ -81,7 +81,18 @@ def soft_pre(text):
     </table>
     <div py:content="soft_pre(comment.body)" py:strip="True"></div>
     <a href="${comment_url(project_id, bug.uuid, comment.uuid)}">Edit</a>
+    <a href="${comment_url(project_id, bug.uuid, comment.uuid, 
+                           action='Reply')}">Reply</a>
     </insetbox>
+    <div style="margin-left:20px;">
+    <div py:for="child, grandchildren in children" py:strip="True">
+    ${show_comment(child, grandchildren)}
+    </div>
+    </div>
+</div>
+<div py:for="comment, children in thread_comments(bug.list_comments())" 
+     py:strip="True">
+    ${show_comment(comment, children)}
 </div>
 <p><input type="submit" name="action" value="Update"/></p>
 <p><input type="submit" name="action" value="New comment"/></p>