Added support for creating and editing comments
authorAaron Bentley <abentley@panoramicfeedback.com>
Wed, 21 Dec 2005 21:55:55 +0000 (16:55 -0500)
committerAaron Bentley <abentley@panoramicfeedback.com>
Wed, 21 Dec 2005 21:55:55 +0000 (16:55 -0500)
.be/bugs/c592a1e8-f2c8-4dfb-8550-955123073947/values
beweb/beweb/controllers.py
beweb/beweb/templates/edit_bug.kid

index 7f0ab440cd33918e74d90ed821a48aa1f1af747a..e854f0ea16feceb7137ef34beb62e9d4086e799b 100644 (file)
@@ -15,7 +15,7 @@ severity=minor
 
 
 
-status=open
+status=closed
 
 
 
index 6fc927753b20ace25949a5de2f409fe2f7be0e99..5b458d8b4767173982fb5e7d3c83addb85c5567c 100644 (file)
@@ -1,7 +1,7 @@
 import turbogears
 from turbogears import controllers
 import cherrypy
-from libbe.bugdir import tree_root, cmp_severity, new_bug
+from libbe.bugdir import tree_root, cmp_severity, new_bug, new_comment
 from libbe import names
 from config import projects
 from prest import PrestHandler, provide_action
@@ -19,7 +19,41 @@ def expose_resource(html=None):
         return func
     return exposer 
 
+def comment_url(project, bug, comment):
+    return turbogears.url("/project/%s/bug/%s/comment/%s" %
+                          (project, bug, comment))
+
+class Comment(PrestHandler):
+    @provide_action("action", "New comment")
+    def new_comment(self, comment_data, comment, *args, **kwargs):
+        bug_tree = project_tree(comment_data['project'])
+        bug = bug_tree.get_bug(comment_data['bug'])
+        comment = new_comment(bug, "")
+        comment.save()
+        raise cherrypy.HTTPRedirect(comment_url(comment=comment.uuid, 
+                                    **comment_data))
+
+    @provide_action("action", "Update")
+    def update(self, comment_data, comment, comment_body, *args, **kwargs):
+        comment.body = comment_body
+        comment.save()
+        raise cherrypy.HTTPRedirect(bug_url(comment_data['project'], 
+                                            comment_data['bug']))
+
+    def instantiate(self, project, bug, comment):
+        bug_tree = project_tree(project)
+        bug = bug_tree.get_bug(bug)
+        return bug.get_comment(comment)
+
+    def dispatch(self, comment_data, comment, *args, **kwargs):
+        return self.edit_comment(comment_data['project'], comment)
+
+    @turbogears.expose(html="beweb.templates.edit_comment")
+    def edit_comment(self, project, comment):
+        return {"comment": comment, "project_id": project}
+
 class Bug(PrestHandler):
+    comment = Comment()
     @turbogears.expose(html="beweb.templates.edit_bug")
     def index(self, project, bug):
         return {"bug": bug, "project_id": project}
@@ -66,6 +100,11 @@ class Bug(PrestHandler):
     def instantiate(self, project, bug):
         return project_tree(project).get_bug(bug)
 
+    @provide_action("action", "New comment")
+    def new_comment(self, bug_data, bug, *args, **kwargs):
+        return self.comment.new_comment(bug_data, comment=None, *args, 
+                                         **kwargs)
+
 
 def project_url(project_id=None):
     project_url = "/project/"
index b328d82939fdbaccea395144f13e97047fd43076..49dbe52cb613552ddb66ef7af96b0d0541b0a5b7 100644 (file)
@@ -2,7 +2,7 @@
 <?python
 from libbe.bugdir import severity_levels
 from libbe.utility import time_to_str 
-from beweb.controllers import bug_list_url
+from beweb.controllers import bug_list_url, comment_url
 def select_among(name, options, default):
     output = ['<select name="%s">' % name]
     for option in options:
@@ -36,9 +36,11 @@ def select_among(name, options, default):
         <tr><td>Date</td><td>${time_to_str(comment.date)}</td></tr>
     </table>
     <pre>${comment.body}</pre>
+    <a href="${comment_url(project_id, bug.uuid, comment.uuid)}">Edit</a>
     </insetbox>
 </div>
 <p><input type="submit" name="action" value="Update"/></p>
+<p><input type="submit" name="action" value="New comment"/></p>
 </form>
 <a href="${bug_list_url(project_id)}">Bug List</a>
 </body>