I can has commenting!
authorSteve Losh <steve@stevelosh.com>
Sun, 1 Feb 2009 21:09:50 +0000 (16:09 -0500)
committerSteve Losh <steve@stevelosh.com>
Sun, 1 Feb 2009 21:09:50 +0000 (16:09 -0500)
cfbe.py
static/style/cfbe.css
templates/base.html
templates/bug.html

diff --git a/cfbe.py b/cfbe.py
index b061d882b3dda6354033f5a21020fd833fa3fe7a..0a8db776d0ab58ee48501df0bc4bd6ac5f234713 100755 (executable)
--- a/cfbe.py
+++ b/cfbe.py
@@ -52,6 +52,7 @@ class WebInterface:
         
         return bugs
     
+    
     @cherrypy.expose
     def index(self, status='open', assignee='', target=''):
         self.bd.load_all_bugs()
@@ -78,6 +79,7 @@ class WebInterface:
                                statuses=common_info['possible_statuses'],
                                repository_name=common_info['repository_name'])
     
+    
     @cherrypy.expose
     def bug(self, id=''):
         """The page for viewing a single bug."""
@@ -94,12 +96,27 @@ class WebInterface:
                                statuses=common_info['possible_statuses'],
                                repository_name=common_info['repository_name'])
     
+    
     @cherrypy.expose
     def create(self, summary):
         """The view that handles the creation of a new bug."""
         if summary.strip() != '':
             self.bd.new_bug(summary=summary).save()
         raise cherrypy.HTTPRedirect('/', status=302)
+    
+    
+    @cherrypy.expose
+    def comment(self, id, body):
+        """The view that handles adding a comment."""
+        bug = self.bd.bug_from_uuid(id)
+        shortname = self.bd.bug_shortname(bug)
+        
+        if body.strip() != '':
+            bug.comment_root.new_reply(body=body)
+            bug.save()
+        
+        raise cherrypy.HTTPRedirect('/bug?id=%s' % (shortname,), status=302)
+    
 
 config = '/Users/sjl/Documents/cherryflavoredbugseverywhere/cfbe.config'
 bug_root = '/Users/sjl/Desktop/be/.be'
index 55bf6b2c0fdd463707c9eb8393695ed3ae71e554..2ad25fcfd9f69068aab0d0adb5151b04c3fbb089 100644 (file)
@@ -45,4 +45,7 @@ h4.bug-comment-header { margin: 1.5em 0em 0em; }
 form#create-form { height: 3em; display: none; }
 form#create-form div.field { }
 form#create-form input#create-summary { width: 30em; font-weight: 700; }
-form#create-form button#create-button { }
\ No newline at end of file
+form#create-form button#create-button { }
+
+form#add-comment-form { display: none; margin-top: 1.5em; }
+p#add-comment-link {margin-top: 1.5em; }
\ No newline at end of file
index 40ec10f115c38000e77b7c401b224850a85f5b4b..c860e659d76f0ca0ec70f623053240c687e9e6e0 100644 (file)
                     e.preventDefault();
                 });
                 
+                $('#add-comment').click(function(e) {
+                    $('#add-comment-link').hide();
+                    $('#add-comment-form').fadeIn('fast');
+                    e.preventDefault();
+                });
+                
                 $('table tr:odd').addClass('stripe');
             });
         </script>
index ee359f769aa25131cbf338d55e30cb259415729a..2cdbb280d52b731db4f907b3d079948b5256b39b 100644 (file)
     <h3>Comments</h3>
     {% for comment in bug.comments() %}
         <div class="bug-comment">
-            <h4 class="bug-comment-header">{{ comment.From|e }} said:</h4>
+            <h4 class="bug-comment-header">{{ comment.From|striptags|e }} said:</h4>
             <p class="bug-comment-body">{{ comment.body|trim|e }}</p>
             <p class="bug-comment-footer">on {{ comment.time|datetimeformat }}</p>
         </div>
     {% endfor %}
+    <form id="add-comment-form" class="vertical" action="/comment" method="post">
+        <fieldset>
+            <input type="hidden" name="id" value="{{ bug.uuid }}" />
+            <div class="field">
+                <label for="add-comment-body">Comment</label>
+                <textarea cols="60" rows="6" id="add-comment-body" name="body"></textarea>
+            </div>
+            <div class="buttons">
+                <button type="submit">Submit</button>
+            </div>
+        </fieldset>
+    </form>
+    <p id="add-comment-link"><a href="" id="add-comment">&#43; Add a comment</a></p>
 {% endblock %}
\ No newline at end of file