Show More
@@ -463,6 +463,11 b' def make_map(config):' | |||||
463 | action='comment', conditions=dict(function=check_repo, |
|
463 | action='comment', conditions=dict(function=check_repo, | |
464 | method=["POST"])) |
|
464 | method=["POST"])) | |
465 |
|
465 | |||
|
466 | rmap.connect('pullrequest_comment_delete', | |||
|
467 | '/{repo_name:.*}/pull-request-comment/{comment_id}/delete', | |||
|
468 | controller='pullrequests', action='delete_comment', | |||
|
469 | conditions=dict(function=check_repo, method=["DELETE"])) | |||
|
470 | ||||
466 | rmap.connect('summary_home', '/{repo_name:.*}/summary', |
|
471 | rmap.connect('summary_home', '/{repo_name:.*}/summary', | |
467 | controller='summary', conditions=dict(function=check_repo)) |
|
472 | controller='summary', conditions=dict(function=check_repo)) | |
468 |
|
473 |
@@ -25,7 +25,7 b'' | |||||
25 | import logging |
|
25 | import logging | |
26 | import traceback |
|
26 | import traceback | |
27 |
|
27 | |||
28 | from webob.exc import HTTPNotFound |
|
28 | from webob.exc import HTTPNotFound, HTTPForbidden | |
29 | from collections import defaultdict |
|
29 | from collections import defaultdict | |
30 | from itertools import groupby |
|
30 | from itertools import groupby | |
31 |
|
31 | |||
@@ -39,7 +39,8 b' from rhodecode.lib.auth import LoginRequ' | |||||
39 | from rhodecode.lib import helpers as h |
|
39 | from rhodecode.lib import helpers as h | |
40 | from rhodecode.lib import diffs |
|
40 | from rhodecode.lib import diffs | |
41 | from rhodecode.lib.utils import action_logger |
|
41 | from rhodecode.lib.utils import action_logger | |
42 | from rhodecode.model.db import User, PullRequest, ChangesetStatus |
|
42 | from rhodecode.model.db import User, PullRequest, ChangesetStatus,\ | |
|
43 | ChangesetComment | |||
43 | from rhodecode.model.pull_request import PullRequestModel |
|
44 | from rhodecode.model.pull_request import PullRequestModel | |
44 | from rhodecode.model.meta import Session |
|
45 | from rhodecode.model.meta import Session | |
45 | from rhodecode.model.repo import RepoModel |
|
46 | from rhodecode.model.repo import RepoModel | |
@@ -189,7 +190,8 b' class PullrequestsController(BaseRepoCon' | |||||
189 | for f in _parsed: |
|
190 | for f in _parsed: | |
190 | fid = h.FID('', f['filename']) |
|
191 | fid = h.FID('', f['filename']) | |
191 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) |
|
192 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) | |
192 |
diff = diff_processor.as_html(enable_comments= |
|
193 | diff = diff_processor.as_html(enable_comments=True, | |
|
194 | diff_lines=[f]) | |||
193 | c.changes[fid] = [f['operation'], f['filename'], diff] |
|
195 | c.changes[fid] = [f['operation'], f['filename'], diff] | |
194 |
|
196 | |||
195 | def show(self, repo_name, pull_request_id): |
|
197 | def show(self, repo_name, pull_request_id): | |
@@ -295,3 +297,14 b' class PullrequestsController(BaseRepoCon' | |||||
295 | render('changeset/changeset_comment_block.html')}) |
|
297 | render('changeset/changeset_comment_block.html')}) | |
296 |
|
298 | |||
297 | return data |
|
299 | return data | |
|
300 | ||||
|
301 | @jsonify | |||
|
302 | def delete_comment(self, repo_name, comment_id): | |||
|
303 | co = ChangesetComment.get(comment_id) | |||
|
304 | owner = lambda: co.author.user_id == c.rhodecode_user.user_id | |||
|
305 | if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner: | |||
|
306 | ChangesetCommentsModel().delete(comment=co) | |||
|
307 | Session.commit() | |||
|
308 | return True | |||
|
309 | else: | |||
|
310 | raise HTTPForbidden() No newline at end of file |
@@ -125,6 +125,8 b'' | |||||
125 | <script> |
|
125 | <script> | |
126 | var _USERS_AC_DATA = ${c.users_array|n}; |
|
126 | var _USERS_AC_DATA = ${c.users_array|n}; | |
127 | var _GROUPS_AC_DATA = ${c.users_groups_array|n}; |
|
127 | var _GROUPS_AC_DATA = ${c.users_groups_array|n}; | |
|
128 | AJAX_COMMENT_URL = "${url('changeset_comment',repo_name=c.repo_name,revision=c.changeset.raw_id)}"; | |||
|
129 | AJAX_COMMENT_DELETE_URL = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}"; | |||
128 | </script> |
|
130 | </script> | |
129 | ## diff block |
|
131 | ## diff block | |
130 | <%namespace name="diff_block" file="/changeset/diff_block.html"/> |
|
132 | <%namespace name="diff_block" file="/changeset/diff_block.html"/> | |
@@ -132,16 +134,15 b'' | |||||
132 |
|
134 | |||
133 | ## template for inline comment form |
|
135 | ## template for inline comment form | |
134 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
136 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> | |
135 |
${comment.comment_inline_form( |
|
137 | ${comment.comment_inline_form()} | |
136 |
|
138 | |||
137 | ## render comments main comments form and it status |
|
139 | ## render comments main comments form and it status | |
138 | ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id), |
|
140 | ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id), | |
139 | h.changeset_status(c.rhodecode_db_repo, c.changeset.raw_id))} |
|
141 | h.changeset_status(c.rhodecode_db_repo, c.changeset.raw_id))} | |
140 |
|
142 | |||
|
143 | ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS | |||
141 | <script type="text/javascript"> |
|
144 | <script type="text/javascript"> | |
142 | YUE.onDOMReady(function(){ |
|
145 | YUE.onDOMReady(function(){ | |
143 | AJAX_COMMENT_URL = "${url('changeset_comment',repo_name=c.repo_name,revision=c.changeset.raw_id)}"; |
|
|||
144 | AJAX_COMMENT_DELETE_URL = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}" |
|
|||
145 | YUE.on(YUQ('.show-inline-comments'),'change',function(e){ |
|
146 | YUE.on(YUQ('.show-inline-comments'),'change',function(e){ | |
146 | var show = 'none'; |
|
147 | var show = 'none'; | |
147 | var target = e.currentTarget; |
|
148 | var target = e.currentTarget; | |
@@ -167,7 +168,6 b'' | |||||
167 | // inject comments into they proper positions |
|
168 | // inject comments into they proper positions | |
168 | var file_comments = YUQ('.inline-comment-placeholder'); |
|
169 | var file_comments = YUQ('.inline-comment-placeholder'); | |
169 | renderInlineComments(file_comments); |
|
170 | renderInlineComments(file_comments); | |
170 |
|
||||
171 | }) |
|
171 | }) | |
172 |
|
172 | |||
173 | </script> |
|
173 | </script> |
@@ -35,12 +35,12 b'' | |||||
35 | </%def> |
|
35 | </%def> | |
36 |
|
36 | |||
37 |
|
37 | |||
38 |
<%def name="comment_inline_form( |
|
38 | <%def name="comment_inline_form()"> | |
39 | <div id='comment-inline-form-template' style="display:none"> |
|
39 | <div id='comment-inline-form-template' style="display:none"> | |
40 | <div class="comment-inline-form ac"> |
|
40 | <div class="comment-inline-form ac"> | |
41 | %if c.rhodecode_user.username != 'default': |
|
41 | %if c.rhodecode_user.username != 'default': | |
42 | <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div> |
|
42 | <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div> | |
43 | ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=changeset.raw_id),class_='inline-form')} |
|
43 | ${h.form('#', class_='inline-form')} | |
44 | <div class="clearfix"> |
|
44 | <div class="clearfix"> | |
45 | <div class="comment-help">${_('Commenting on line {1}.')} |
|
45 | <div class="comment-help">${_('Commenting on line {1}.')} | |
46 | ${(_('Comments parsed using %s syntax with %s support.') % ( |
|
46 | ${(_('Comments parsed using %s syntax with %s support.') % ( |
@@ -83,6 +83,8 b'' | |||||
83 | <script> |
|
83 | <script> | |
84 | var _USERS_AC_DATA = ${c.users_array|n}; |
|
84 | var _USERS_AC_DATA = ${c.users_array|n}; | |
85 | var _GROUPS_AC_DATA = ${c.users_groups_array|n}; |
|
85 | var _GROUPS_AC_DATA = ${c.users_groups_array|n}; | |
|
86 | AJAX_COMMENT_URL = "${url('pullrequest_comment',repo_name=c.repo_name,pull_request_id=c.pull_request.pull_request_id)}"; | |||
|
87 | AJAX_COMMENT_DELETE_URL = "${url('pullrequest_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}"; | |||
86 | </script> |
|
88 | </script> | |
87 |
|
89 | |||
88 | ## diff block |
|
90 | ## diff block | |
@@ -93,12 +95,46 b'' | |||||
93 |
|
95 | |||
94 | ## template for inline comment form |
|
96 | ## template for inline comment form | |
95 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
97 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> | |
96 |
|
|
98 | ${comment.comment_inline_form()} | |
97 |
|
99 | |||
98 | ## render comments main comments form and it status |
|
100 | ## render comments main comments form and it status | |
99 | ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id), |
|
101 | ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id), | |
100 | c.current_changeset_status)} |
|
102 | c.current_changeset_status)} | |
101 |
|
103 | |||
|
104 | ||||
|
105 | <script type="text/javascript"> | |||
|
106 | YUE.onDOMReady(function(){ | |||
|
107 | ||||
|
108 | YUE.on(YUQ('.show-inline-comments'),'change',function(e){ | |||
|
109 | var show = 'none'; | |||
|
110 | var target = e.currentTarget; | |||
|
111 | if(target.checked){ | |||
|
112 | var show = '' | |||
|
113 | } | |||
|
114 | var boxid = YUD.getAttribute(target,'id_for'); | |||
|
115 | var comments = YUQ('#{0} .inline-comments'.format(boxid)); | |||
|
116 | for(c in comments){ | |||
|
117 | YUD.setStyle(comments[c],'display',show); | |||
|
118 | } | |||
|
119 | var btns = YUQ('#{0} .inline-comments-button'.format(boxid)); | |||
|
120 | for(c in btns){ | |||
|
121 | YUD.setStyle(btns[c],'display',show); | |||
|
122 | } | |||
|
123 | }) | |||
|
124 | ||||
|
125 | YUE.on(YUQ('.line'),'click',function(e){ | |||
|
126 | var tr = e.currentTarget; | |||
|
127 | injectInlineForm(tr); | |||
|
128 | }); | |||
|
129 | ||||
|
130 | // inject comments into they proper positions | |||
|
131 | var file_comments = YUQ('.inline-comment-placeholder'); | |||
|
132 | renderInlineComments(file_comments); | |||
|
133 | }) | |||
|
134 | ||||
|
135 | </script> | |||
|
136 | ||||
|
137 | ||||
102 | </div> |
|
138 | </div> | |
103 |
|
139 | |||
104 | </%def> |
|
140 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now