# HG changeset patch # User Marcin Kuzminski # Date 2011-11-12 15:09:17 # Node ID 6f0143e5efe55e2f6a64b4b11332df7f9de1c9b9 # Parent 333b3e7c991fab29ddd28aabf03ff10e781023f1 #71 code review - added delete of comments by owner or admin diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -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}', diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -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() + diff --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -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; +} diff --git a/rhodecode/public/js/rhodecode.js b/rhodecode/public/js/rhodecode.js --- a/rhodecode/public/js/rhodecode.js +++ b/rhodecode/public/js/rhodecode.js @@ -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); +}; - diff --git a/rhodecode/templates/changeset/changeset.html b/rhodecode/templates/changeset/changeset.html --- a/rhodecode/templates/changeset/changeset.html +++ b/rhodecode/templates/changeset/changeset.html @@ -158,6 +158,17 @@ %endif - + diff --git a/rhodecode/templates/changeset/changeset_file_comment.html b/rhodecode/templates/changeset/changeset_file_comment.html --- a/rhodecode/templates/changeset/changeset_file_comment.html +++ b/rhodecode/templates/changeset/changeset_file_comment.html @@ -22,7 +22,7 @@
%if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id:
- ${_('Delete')} + ${_('Delete')}
%endif ${h.rst(co.text)|n}