diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -463,6 +463,11 @@ def make_map(config): action='comment', conditions=dict(function=check_repo, method=["POST"])) + rmap.connect('pullrequest_comment_delete', + '/{repo_name:.*}/pull-request-comment/{comment_id}/delete', + controller='pullrequests', action='delete_comment', + conditions=dict(function=check_repo, method=["DELETE"])) + rmap.connect('summary_home', '/{repo_name:.*}/summary', controller='summary', conditions=dict(function=check_repo)) diff --git a/rhodecode/controllers/pullrequests.py b/rhodecode/controllers/pullrequests.py --- a/rhodecode/controllers/pullrequests.py +++ b/rhodecode/controllers/pullrequests.py @@ -25,7 +25,7 @@ import logging import traceback -from webob.exc import HTTPNotFound +from webob.exc import HTTPNotFound, HTTPForbidden from collections import defaultdict from itertools import groupby @@ -39,7 +39,8 @@ from rhodecode.lib.auth import LoginRequ from rhodecode.lib import helpers as h from rhodecode.lib import diffs from rhodecode.lib.utils import action_logger -from rhodecode.model.db import User, PullRequest, ChangesetStatus +from rhodecode.model.db import User, PullRequest, ChangesetStatus,\ + ChangesetComment from rhodecode.model.pull_request import PullRequestModel from rhodecode.model.meta import Session from rhodecode.model.repo import RepoModel @@ -189,7 +190,8 @@ class PullrequestsController(BaseRepoCon for f in _parsed: fid = h.FID('', f['filename']) c.files.append([fid, f['operation'], f['filename'], f['stats']]) - diff = diff_processor.as_html(enable_comments=False, diff_lines=[f]) + diff = diff_processor.as_html(enable_comments=True, + diff_lines=[f]) c.changes[fid] = [f['operation'], f['filename'], diff] def show(self, repo_name, pull_request_id): @@ -295,3 +297,14 @@ class PullrequestsController(BaseRepoCon render('changeset/changeset_comment_block.html')}) return data + + @jsonify + def delete_comment(self, repo_name, comment_id): + co = ChangesetComment.get(comment_id) + owner = lambda: co.author.user_id == c.rhodecode_user.user_id + if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner: + ChangesetCommentsModel().delete(comment=co) + Session.commit() + return True + else: + raise HTTPForbidden() \ No newline at end of file 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 @@ -125,6 +125,8 @@ ## diff block <%namespace name="diff_block" file="/changeset/diff_block.html"/> @@ -132,16 +134,15 @@ ## template for inline comment form <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> - ${comment.comment_inline_form(c.changeset)} + ${comment.comment_inline_form()} ## render comments main comments form and it status ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id), h.changeset_status(c.rhodecode_db_repo, c.changeset.raw_id))} + ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS 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 @@ -35,12 +35,12 @@ %def> -<%def name="comment_inline_form(changeset)"> +<%def name="comment_inline_form()">