aboutsummaryrefslogtreecommitdiffstats
path: root/beweb
diff options
context:
space:
mode:
authorAaron Bentley <abentley@panoramicfeedback.com>2005-12-21 16:55:55 -0500
committerAaron Bentley <abentley@panoramicfeedback.com>2005-12-21 16:55:55 -0500
commit167db8bdcc3889f0754e2b2c3a56286e61e81c38 (patch)
tree6b4818a241f8a6c5a7e7776e80fd47743232317e /beweb
parent8529a6d8278fb0e3a98a41aa8224c8ea8e7f8acf (diff)
downloadbugseverywhere-167db8bdcc3889f0754e2b2c3a56286e61e81c38.tar.gz
Added support for creating and editing comments
Diffstat (limited to 'beweb')
-rw-r--r--beweb/beweb/controllers.py41
-rw-r--r--beweb/beweb/templates/edit_bug.kid4
2 files changed, 43 insertions, 2 deletions
diff --git a/beweb/beweb/controllers.py b/beweb/beweb/controllers.py
index 6fc9277..5b458d8 100644
--- a/beweb/beweb/controllers.py
+++ b/beweb/beweb/controllers.py
@@ -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/"
diff --git a/beweb/beweb/templates/edit_bug.kid b/beweb/beweb/templates/edit_bug.kid
index b328d82..49dbe52 100644
--- a/beweb/beweb/templates/edit_bug.kid
+++ b/beweb/beweb/templates/edit_bug.kid
@@ -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>