Show More
@@ -169,7 +169,7 b' class PullrequestsController(BaseRepoCon' | |||
|
169 | 169 | return redirect(url('pullrequest_show', repo_name=other_repo, |
|
170 | 170 | pull_request_id=pull_request.pull_request_id)) |
|
171 | 171 | |
|
172 | def _load_compare_data(self, pull_request): | |
|
172 | def _load_compare_data(self, pull_request, enable_comments=True): | |
|
173 | 173 | """ |
|
174 | 174 | Load context data needed for generating compare diff |
|
175 | 175 | |
@@ -211,7 +211,7 b' class PullrequestsController(BaseRepoCon' | |||
|
211 | 211 | for f in _parsed: |
|
212 | 212 | fid = h.FID('', f['filename']) |
|
213 | 213 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) |
|
214 |
diff = diff_processor.as_html(enable_comments= |
|
|
214 | diff = diff_processor.as_html(enable_comments=enable_comments, | |
|
215 | 215 | diff_lines=[f]) |
|
216 | 216 | c.changes[fid] = [f['operation'], f['filename'], diff] |
|
217 | 217 | |
@@ -246,7 +246,8 b' class PullrequestsController(BaseRepoCon' | |||
|
246 | 246 | raise HTTPNotFound |
|
247 | 247 | |
|
248 | 248 | # load compare data into template context |
|
249 |
|
|
|
249 | enable_comments = not c.pull_request.is_closed() | |
|
250 | self._load_compare_data(c.pull_request, enable_comments=enable_comments) | |
|
250 | 251 | |
|
251 | 252 | # inline comments |
|
252 | 253 | c.inline_cnt = 0 |
@@ -271,6 +272,9 b' class PullrequestsController(BaseRepoCon' | |||
|
271 | 272 | |
|
272 | 273 | @jsonify |
|
273 | 274 | def comment(self, repo_name, pull_request_id): |
|
275 | pull_request = PullRequest.get_or_404(pull_request_id) | |
|
276 | if pull_request.is_closed(): | |
|
277 | raise HTTPForbidden() | |
|
274 | 278 | |
|
275 | 279 | status = request.POST.get('changeset_status') |
|
276 | 280 | change_status = request.POST.get('change_changeset_status') |
@@ -299,6 +303,12 b' class PullrequestsController(BaseRepoCon' | |||
|
299 | 303 | 'user_commented_pull_request:%s' % pull_request_id, |
|
300 | 304 | c.rhodecode_db_repo, self.ip_addr, self.sa) |
|
301 | 305 | |
|
306 | if request.POST.get('save_close'): | |
|
307 | PullRequestModel().close_pull_request(pull_request_id) | |
|
308 | action_logger(self.rhodecode_user, | |
|
309 | 'user_closed_pull_request:%s' % pull_request_id, | |
|
310 | c.rhodecode_db_repo, self.ip_addr, self.sa) | |
|
311 | ||
|
302 | 312 | Session().commit() |
|
303 | 313 | |
|
304 | 314 | if not request.environ.get('HTTP_X_PARTIAL_XHR'): |
@@ -319,6 +329,10 b' class PullrequestsController(BaseRepoCon' | |||
|
319 | 329 | @jsonify |
|
320 | 330 | def delete_comment(self, repo_name, comment_id): |
|
321 | 331 | co = ChangesetComment.get(comment_id) |
|
332 | if co.pull_request.is_closed(): | |
|
333 | #don't allow deleting comments on closed pull request | |
|
334 | raise HTTPForbidden() | |
|
335 | ||
|
322 | 336 | owner = lambda: co.author.user_id == c.rhodecode_user.user_id |
|
323 | 337 | if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner: |
|
324 | 338 | ChangesetCommentsModel().delete(comment=co) |
@@ -1519,6 +1519,7 b' class PullRequest(Base, BaseModel):' | |||
|
1519 | 1519 | description = Column('description', UnicodeText(10240), nullable=True) |
|
1520 | 1520 | status = Column('status', Unicode(256), nullable=False, default=STATUS_NEW) |
|
1521 | 1521 | created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now) |
|
1522 | updated_on = Column('updated_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now) | |
|
1522 | 1523 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None) |
|
1523 | 1524 | _revisions = Column('revisions', UnicodeText(20500)) # 500 revisions max |
|
1524 | 1525 | org_repo_id = Column('org_repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False) |
@@ -1526,6 +1527,8 b' class PullRequest(Base, BaseModel):' | |||
|
1526 | 1527 | other_repo_id = Column('other_repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False) |
|
1527 | 1528 | other_ref = Column('other_ref', Unicode(256), nullable=False) |
|
1528 | 1529 | |
|
1530 | statuses = relationship('ChangesetStatus') | |
|
1531 | ||
|
1529 | 1532 | @hybrid_property |
|
1530 | 1533 | def revisions(self): |
|
1531 | 1534 | return self._revisions.split(':') |
@@ -1539,6 +1542,9 b' class PullRequest(Base, BaseModel):' | |||
|
1539 | 1542 | org_repo = relationship('Repository', primaryjoin='PullRequest.org_repo_id==Repository.repo_id') |
|
1540 | 1543 | other_repo = relationship('Repository', primaryjoin='PullRequest.other_repo_id==Repository.repo_id') |
|
1541 | 1544 | |
|
1545 | def is_closed(self): | |
|
1546 | return self.status == self.STATUS_CLOSED | |
|
1547 | ||
|
1542 | 1548 | def __json__(self): |
|
1543 | 1549 | return dict( |
|
1544 | 1550 | revisions=self.revisions |
@@ -1,7 +1,7 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 |
rhodecode.model.pull_re |
|
|
4 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
3 | rhodecode.model.pull_request | |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
|
5 | 5 | |
|
6 | 6 | pull request model for RhodeCode |
|
7 | 7 | |
@@ -25,6 +25,7 b'' | |||
|
25 | 25 | |
|
26 | 26 | import logging |
|
27 | 27 | import binascii |
|
28 | import datetime | |
|
28 | 29 | |
|
29 | 30 | from pylons.i18n.translation import _ |
|
30 | 31 | |
@@ -44,6 +45,9 b' class PullRequestModel(BaseModel):' | |||
|
44 | 45 | |
|
45 | 46 | cls = PullRequest |
|
46 | 47 | |
|
48 | def __get_pull_request(self, pull_request): | |
|
49 | return self._get_instance(PullRequest, pull_request) | |
|
50 | ||
|
47 | 51 | def get_all(self, repo): |
|
48 | 52 | repo = self._get_repo(repo) |
|
49 | 53 | return PullRequest.query().filter(PullRequest.other_repo == repo).all() |
@@ -93,6 +97,12 b' class PullRequestModel(BaseModel):' | |||
|
93 | 97 | |
|
94 | 98 | return new |
|
95 | 99 | |
|
100 | def close_pull_request(self, pull_request): | |
|
101 | pull_request = self.__get_pull_request(pull_request) | |
|
102 | pull_request.status = PullRequest.STATUS_CLOSED | |
|
103 | pull_request.updated_on = datetime.datetime.now() | |
|
104 | self.sa.add(pull_request) | |
|
105 | ||
|
96 | 106 | def _get_changesets(self, org_repo, org_ref, other_repo, other_ref, |
|
97 | 107 | discovery_data): |
|
98 | 108 | """ |
@@ -396,7 +396,8 b' var injectInlineForm = function(tr){' | |||
|
396 | 396 | return |
|
397 | 397 | } |
|
398 | 398 | var submit_url = AJAX_COMMENT_URL; |
|
399 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(tr,'no-comment')){ | |
|
399 | var _td = tr.getElementsByClassName('code')[0]; | |
|
400 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ | |
|
400 | 401 | return |
|
401 | 402 | } |
|
402 | 403 | YUD.addClass(tr,'form-open'); |
@@ -136,7 +136,10 b'' | |||
|
136 | 136 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
137 | 137 | ${comment.comment_inline_form()} |
|
138 | 138 | |
|
139 |
## render comments |
|
|
139 | ## render comments and inlines | |
|
140 | ${comment.generate_comments()} | |
|
141 | ||
|
142 | ## main comment form and it status | |
|
140 | 143 | ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id), |
|
141 | 144 | h.changeset_status(c.rhodecode_db_repo, c.changeset.raw_id))} |
|
142 | 145 |
@@ -92,9 +92,8 b'' | |||
|
92 | 92 | |
|
93 | 93 | </%def> |
|
94 | 94 | |
|
95 | ## MAIN COMMENT FORM | |
|
96 |
<%def name="comments( |
|
|
97 | ||
|
95 | ## generate inline comments and the main ones | |
|
96 | <%def name="generate_comments()"> | |
|
98 | 97 | <div class="comments"> |
|
99 | 98 | <div id="inline-comments-container"> |
|
100 | 99 | ## generate inlines for this changeset |
@@ -106,6 +105,13 b'' | |||
|
106 | 105 | ${comment_block(co)} |
|
107 | 106 | </div> |
|
108 | 107 | %endfor |
|
108 | </div> | |
|
109 | </%def> | |
|
110 | ||
|
111 | ## MAIN COMMENT FORM | |
|
112 | <%def name="comments(post_url, cur_status, close_btn=False)"> | |
|
113 | ||
|
114 | <div class="comments"> | |
|
109 | 115 | %if c.rhodecode_user.username != 'default': |
|
110 | 116 | <div class="comment-form ac"> |
|
111 | 117 | ${h.form(post_url)} |
@@ -129,7 +135,10 b'' | |||
|
129 | 135 | ${h.textarea('text')} |
|
130 | 136 | </div> |
|
131 | 137 | <div class="comment-button"> |
|
132 |
${h.submit('save', _('Comment'), class_= |
|
|
138 | ${h.submit('save', _('Comment'), class_="ui-btn large")} | |
|
139 | %if close_btn: | |
|
140 | ${h.submit('save_close', _('Comment and close'), class_='ui-btn blue large')} | |
|
141 | %endif | |
|
133 | 142 | </div> |
|
134 | 143 | ${h.end_form()} |
|
135 | 144 | </div> |
@@ -19,12 +19,14 b'' | |||
|
19 | 19 | <div class="title"> |
|
20 | 20 | ${self.breadcrumbs()} |
|
21 | 21 | </div> |
|
22 | ||
|
22 | %if c.pull_request.is_closed(): | |
|
23 | <div style="padding:10px; font-size:22px;width:100%;text-align: center; color:#88D882">${_('Closed %s') % (h.age(c.pull_request.updated_on))}</div> | |
|
24 | %endif | |
|
23 | 25 | <h3>${_('Title')}: ${c.pull_request.title} |
|
24 | 26 | <div class="changeset-status-container" style="float:none"> |
|
25 | 27 | %if c.current_changeset_status: |
|
26 | 28 | <div title="${_('Pull request status')}" class="changeset-status-lbl">[${h.changeset_status_lbl(c.current_changeset_status)}]</div> |
|
27 | <div class="changeset-status-ico" style="padding:4px"><img src="${h.url('/images/icons/flag_status_%s.png' % c.current_changeset_status)}" /></div> | |
|
29 | <div class="changeset-status-ico" style="padding:4px"><img src="${h.url('/images/icons/flag_status_%s.png' % c.current_changeset_status)}" /></div> | |
|
28 | 30 | %endif |
|
29 | 31 | </div> |
|
30 | 32 | </h3> |
@@ -96,11 +98,17 b'' | |||
|
96 | 98 | ## template for inline comment form |
|
97 | 99 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
98 | 100 | ${comment.comment_inline_form()} |
|
99 | ||
|
100 |
## render comments |
|
|
101 | ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id), | |
|
102 | c.current_changeset_status)} | |
|
103 | ||
|
101 | ||
|
102 | ## render comments and inlines | |
|
103 | ${comment.generate_comments()} | |
|
104 | ||
|
105 | % if not c.pull_request.is_closed(): | |
|
106 | ## main comment form and it status | |
|
107 | ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name, | |
|
108 | pull_request_id=c.pull_request.pull_request_id), | |
|
109 | c.current_changeset_status, | |
|
110 | close_btn=True)} | |
|
111 | %endif | |
|
104 | 112 | |
|
105 | 113 | <script type="text/javascript"> |
|
106 | 114 | YUE.onDOMReady(function(){ |
@@ -131,10 +139,8 b'' | |||
|
131 | 139 | var file_comments = YUQ('.inline-comment-placeholder'); |
|
132 | 140 | renderInlineComments(file_comments); |
|
133 | 141 | }) |
|
134 | ||
|
135 | 142 | </script> |
|
136 | 143 | |
|
137 | ||
|
138 | 144 | </div> |
|
139 | 145 | |
|
140 | 146 | </%def> |
@@ -1,7 +1,7 b'' | |||
|
1 | 1 | <%inherit file="/base/base.html"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 |
${c.repo_name} ${_(' |
|
|
4 | ${c.repo_name} ${_('all pull requests')} | |
|
5 | 5 | </%def> |
|
6 | 6 | |
|
7 | 7 | <%def name="breadcrumbs_links()"> |
@@ -22,7 +22,11 b'' | |||
|
22 | 22 | |
|
23 | 23 | %for pr in c.pull_requests: |
|
24 | 24 | <div> |
|
25 | <h4><a href="${h.url('pullrequest_show',repo_name=c.repo_name,pull_request_id=pr.pull_request_id)}"> | |
|
25 | <h4> | |
|
26 | %if pr.is_closed(): | |
|
27 | <img src="${h.url('/images/icons/tick.png')}" alt="${_('Closed')}" /> | |
|
28 | %endif | |
|
29 | <a href="${h.url('pullrequest_show',repo_name=c.repo_name,pull_request_id=pr.pull_request_id)}"> | |
|
26 | 30 | ${_('Pull request #%s opened by %s on %s') % (pr.pull_request_id, pr.author.full_name, h.fmt_date(pr.created_on))} |
|
27 | 31 | </a> |
|
28 | 32 | </h4> |
General Comments 0
You need to be logged in to leave comments.
Login now