Commits

Marcin Kuzminski committed 3052f90

fixed main comments, prevent from sending inline comments if text is empty

  • Participants
  • Parent commits 56e96d4

Comments (0)

Files changed (3)

rhodecode/controllers/changeset.py

             line_no=request.POST.get('line')
         )
         Session.commit()
+        if not request.environ.get('HTTP_X_PARTIAL_XHR'):
+            return redirect(h.url('changeset_home', repo_name=repo_name,
+                                  revision=revision))
+
         data = {
            'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))),
         }
             data.update(comm.get_dict())
             data.update({'rendered_text':
                          render('changeset/changeset_comment_block.html')})
+
         return data
 
     @jsonify

rhodecode/public/js/rhodecode.js

 };
 
 var ajaxPOST = function(url,postData,success) {
+	// Set special header for ajax == HTTP_X_PARTIAL_XHR
+	YUC.initHeader('X-PARTIAL-XHR',true);
+	
 	var toQueryString = function(o) {
 	    if(typeof o !== 'object') {
 	        return false;
 			  return
 		  }
 		  
+		  if(text == ""){
+			  return
+		  }
+		  
 		  var success = function(o){
 			  YUD.removeClass(tr, 'form-open');
 			  removeInlineForm(f);			  
         n.parentNode.removeChild(n);
 
         // scann nodes, and attach add button to last one
-        placeAddButton(root);        
+        placeAddButton(root);
     }
     ajaxPOST(url,postData,success);
 }

rhodecode/templates/changeset/changeset_file_comment.html

     </div>
 
     %for co in c.comments:
-        ${comment_block(co)}
+        <div id="comment-tr-${co.comment_id}">
+          ${comment_block(co)}
+        </div>
     %endfor
     %if c.rhodecode_user.username != 'default':
     <div class="comment-form">