From: Aaron Bentley Date: Wed, 21 Dec 2005 21:55:55 +0000 (-0500) Subject: Added support for creating and editing comments X-Git-Tag: 1.0.0~250 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=167db8bdcc3889f0754e2b2c3a56286e61e81c38;p=be.git Added support for creating and editing comments --- diff --git a/.be/bugs/c592a1e8-f2c8-4dfb-8550-955123073947/values b/.be/bugs/c592a1e8-f2c8-4dfb-8550-955123073947/values index 7f0ab44..e854f0e 100644 --- a/.be/bugs/c592a1e8-f2c8-4dfb-8550-955123073947/values +++ b/.be/bugs/c592a1e8-f2c8-4dfb-8550-955123073947/values @@ -15,7 +15,7 @@ severity=minor -status=open +status=closed 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 @@ ' % name] for option in options: @@ -36,9 +36,11 @@ def select_among(name, options, default): Date${time_to_str(comment.date)}
${comment.body}
+ Edit

+

Bug List