Changeset - 6f0143e5efe5
[Not reviewed]
beta
0 6 0
Marcin Kuzminski - 14 years ago 2011-11-12 16:09:17
marcin@python-works.com
#71 code review
- added delete of comments by owner or admin
6 files changed with 40 insertions and 14 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -352,7 +352,7 @@ def make_map(config):
 

	
 
    rmap.connect('changeset_comment_delete', '/{repo_name:.*}/changeset/comment/{comment_id}/delete',
 
                controller='changeset', action='delete_comment',
 
                conditions=dict(function=check_repo))
 
                conditions = dict(function=check_repo, method=["DELETE"]))
 

	
 
    rmap.connect('raw_changeset_home',
 
                 '/{repo_name:.*}/raw-changeset/{revision}',
rhodecode/controllers/changeset.py
Show inline comments
 
@@ -44,6 +44,7 @@ from vcs.exceptions import RepositoryErr
 
    ChangesetDoesNotExistError
 
from vcs.nodes import FileNode
 
from vcs.utils import diffs as differ
 
from webob.exc import HTTPForbidden
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -278,8 +279,13 @@ class ChangesetController(BaseRepoContro
 
                              revision=revision))
 

	
 
    @jsonify
 
    @HasRepoPermissionAnyDecorator('hg.admin', 'repository.admin')
 
    def delete_comment(self, comment_id):
 
        ccmodel = ChangesetCommentsModel()
 
        ccmodel.delete(comment_id=comment_id)
 
        return True
 
        co = ChangesetComment.get(comment_id)
 
        if (h.HasPermissionAny('hg.admin', 'repository.admin')() or
 
            co.author.user_id == c.rhodecode_user.user_id):
 
            ccmodel = ChangesetCommentsModel()
 
            ccmodel.delete(comment_id=comment_id)
 
            return True
 
        else:
 
            raise HTTPForbidden()
 

	
rhodecode/public/css/style.css
Show inline comments
 
@@ -3263,9 +3263,8 @@ div.rst-block  pre {
 
}
 
 
.comments .comment .text {
 
    margin-top: 7px;
 
    padding: 6px;
 
    padding-bottom: 13px;
 
    padding: 8px 6px 6px 14px;
 
    background-color: #FAFAFA;
 
}
 
 
.comments .comments-number{
 
@@ -3330,6 +3329,6 @@ form.comment-form {
 
}
 
 
.comment .buttons {
 
    float: right;
 
    display: none;
 
}
 
    position: absolute;
 
    right:40px;
 
}
rhodecode/public/js/rhodecode.js
Show inline comments
 
@@ -286,5 +286,15 @@ var q_filter = function(target,nodes,dis
 
	}	
 
}
 

	
 
var ajaxPOST = function(url,postData,success) {
 
    var sUrl = url;
 
    var callback = {
 
        success: success,
 
        failure: function (o) {
 
            alert("error");
 
        },
 
    };
 
    var postData = postData;
 
    var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
 
};
 

	
 

	
rhodecode/templates/changeset/changeset.html
Show inline comments
 
@@ -158,6 +158,17 @@
 
        </div>
 
        %endif
 
    </div>
 
    
 
    <script type="text/javascript">
 
      var deleteComment = function(comment_id){
 

	
 
          var url = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}".replace('__COMMENT_ID__',comment_id);
 
          var postData = '_method=delete';
 
          var success = function(o){
 
              var n = YUD.get('comment-'+comment_id);
 
              n.parentNode.removeChild(n);
 
          }
 
          ajaxPOST(url,postData,success);
 
      } 
 
    </script> 
 
  </div>	
 
</%def>
rhodecode/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -22,7 +22,7 @@
 
  	<div class="text">
 
  		%if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id:
 
  			<div class="buttons">
 
  				<a href="javascript:void(0);" onClick="deleteComment(${co.comment_id})" class="">${_('Delete')}</a>
 
  				<span onClick="deleteComment(${co.comment_id})" class="delete-comment ui-button-small">${_('Delete')}</span>
 
  			</div>
 
  		%endif
 
  		${h.rst(co.text)|n}
0 comments (0 inline, 0 general)